CP Lab 3
CP Lab 3
CP Lab 3
EXERCISE 03
1. Write a single C++ statement to accomplish each of the following (assume that
using directives have not been used):
1
19CS78
2
19CS78
3. Using the statements you wrote in Exercise 2, write a complete program that
calculates and displays the product of three integers. Add comments to the
code where appropriate. [Note: You’ll need to write the necessary using
directives.]
a. cout << x;
b. cout << x + x;
c. cout << "x=";
d. cout << "x = " << x;
e. cout << x + y << " = " << y + x;
f. z = x + y;
g. cin >> x >> y;
h. // cout << "x + y = " << x + y;
i. cout << "\n";
3
19CS78
5. Write a program that asks the user to enter two numbers, obtains the two
numbers from the user and prints the sum, product, difference, and quotient
of the two numbers.
6. Write a program that prints the numbers 1 to 4 on the same line with each
pair of adjacent numbers separated by one space. Do this several ways:
4
19CS78
7. Write a program that reads in the radius of a circle as an integer and prints
the circle’s diameter, circumference and area. Use the constant value 3.14159
for π. Do all calculations in output statements.
8. Write a program that prints a box, an oval, an arrow and a diamond as follows:
5
19CS78
Create a BMI calculator application in C++ that reads the user’s weight in
pounds and height in inches (or, if you prefer, the user’s weight in kilograms
and height in meters), then calculates and displays the user’s body mass
index.