## Chapter 2: Programming Exercise

2.1

Write a program to display the following output using a single cout statement

Maths = 90
Physics = 77
Chemistry = 69

## OUTPUT

Maths = 90
Physics = 77
Chemistry = 69

2.2

Write a program to read two numbers from the keyboard and display the larger value on the screen.

## OUTPUT

Enter two values : 10 20
larger value = 20

2.3

Write a program to input an integer from the keyboard and display on the screen “WELL DONE” that many times.

## OUTPUT

Enter an integer value 5
WELL DONE
WELL DONE
WELL DONE
WELL DONE
WELL DONE

2.4

Write a program to read the values a, b and c and display x, where
x = a / b –c.
Test the program for the following values:
(a) a = 250, b = 85, c = 25
(b) a = 300, b = 70, c = 70

## OUTPUT

Enter the value of a,b, &c : 300 70 70
x= infinity

2.5

Write a C++ program that will ask for a temperature in Fahrenheit and display it in Celsius

## OUTPUT

Enter the temperature in Feranhite scale : 105
Temperature in Celsius = 40.555557

2.6

Redo Exercise 2.5 using a class called temp and member functions.