1 / 13

Lab # 4

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.

socrates
Télécharger la présentation

Lab # 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab # 4

  2. 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)

  3. 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

  4. 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

  5. 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:

  6. Exercise 4 Solution

  7. 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:

  8. Exercise 5 Solution

  9. 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.

  10. Exercise 6 Solution

  11. Exercise 7 Write a program that prints an arrow as follows:

  12. Exercise 7 Solution

More Related