Question

design an algorithm that will display to the screen the first 20 numbers, with their squares...

design an algorithm that will display to the screen the first 20 numbers, with their squares and cubes, as follows:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

int main()
{
cout<<"Number\tSquare\tCube"<<endl;
for(int i=1;i<=20;i++) {
cout<<i<<"\t"<<i*i<<"\t"<<i*i*i<<endl;
}
return 0;
}

Output:

$g++ -o main *.cpp
$main
Number  Square  Cube
1       1       1
2       4       8
3       9       27
4       16      64
5       25      125
6       36      216
7       49      343
8       64      512
9       81      729
10      100     1000
11      121     1331
12      144     1728
13      169     2197
14      196     2744
15      225     3375
16      256     4096
17      289     4913
18      324     5832
19      361     6859
20      400     8000
Add a comment
Know the answer?
Add Answer to:
design an algorithm that will display to the screen the first 20 numbers, with their squares...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT