Directions

  • You are to complete exercise 3.12 in the Deitel text. (Q)
  • Submit as a .cpp file by Sunday at 11:59pm (CST).

Q- What does the following program print?

1// Exercise 3.12: ex03_12.cpp

2// What does this program print?

3#include <iostream>

4using namespace std;

5

6int main()

7{

8int y; // declare y

9int x = 1; // initialize x

10int total = 0; // initialize total

11

12while ( x <= 10 ) // loop 10 times

13 {

14y = x * x; // perform calculation

15cout << y << endl; // output result

16total += y; // add y to total

17x++; // increment counter x

18} // end while

19

20cout << "Total is " << total << endl; // display result

21} // end main

Grading Criteria

 

 

2.19(Arithmetic, Smallest and Largest) Write a program that inputs three integers from the key- board and prints the sum, average, product, smallest and largest of these numbers. The screen dialog should appear as follows:

 

Input three different integers: 13 27 14

Sum is: 54

Average is 18

Product is 4914

Smallest is 13

Largest is 27

 

The due date is Aug 22.

    • 11 years ago
    Programming Assignment 2
    NOT RATED

    Purchase the answer to view it

    • programmingassignment2.zip