Answer to Question #47623 in C++ for jhulliused

Question #47623
a C++ program that uses a iteration statement to generate the square of a number
1
Expert's answer
2014-10-08T10:48:14-0400
Code
#include <iostream>
#include <iomanip>
#define MAX 10

using namespace std;

int main() {
for (int i = 1; i <= MAX; i++) {
cout << i << "^2:" << "\t" << i * i << endl;
}

return 0;
}
Result
1^2: 1
2^2: 4
3^2: 9
4^2: 16
5^2: 25
6^2: 36
7^2: 49
8^2: 64
9^2: 81
10^2: 100

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS