Print Friendly and PDF
(What Does this Program Do?) What does the following program print?

#include<iostream>
using std: : cout;
using std: : endl;
int main()
{
int y; // declare y
int x = 1; // initialize x
int total = 0; // initialize total
while ( x <= 10 ) // loop 10 times
{
y = x * x; // perform calculation
cout << y << endl; // output result
total += y; // add y to total
x++; // increment counter x
} // end while
cout << "Total is " << total << endl; // display result
return 0; // indicate successful termination
} // end main


Solution:

1491
6
25
36
49
64
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: