140 likes | 462 Views
Lab # 4. Exercise 1. Convert each of the following formulas to a C++ expression: 3x 3x + y x+y 3x + y 7 z + 2. 3*x. 3*x + y. ( x+y )/ 7. (3*x + y)/(z+2). Exercise 2.
E N D
Exercise 1 Convert each of the following formulas to a C++ expression:3x 3x + y x+y3x + y 7 z + 2 3*x 3*x + y (x+y)/7 (3*x + y)/(z+2)
Exercise 2 What is the output of the following program lines, when embedded in a correct program that declares all variables to be of type char?a = 'b';b = 'c';c = a;cout << a << b << c << 'c'; bcbc
Exercise 3 What is the output of the following program lines, when embedded in a correct program that declares all variables to be of type int? number = (1/3) * 3;cout << "(1/3) * 3 is equal to “ << number; (1/3)*3 is equal to 0
Exercise 4 Write and run a program that simulates a simple calculator. It reads two integers and performs the simple calculator operations +,-,*, and / on them. The output should appear as follows:
Exercise 5 Write a program that inputs three integers from the keyboard and prints the sum, average, and product. The screen dialog should appear as follows:
Exercise 6 Write a program that asks the user to type the width and the height of a rectangle and then outputs to the screen the area and the perimeter of that rectangle.
Exercise 7 Write a program that prints an arrow as follows: