Hi,

Please some one help in this

To find the Square of the Numbers from 1 to 20 Using

1. For loop 2. While loop 3. Do while loop 4. Goto Statement

# To find the Square of the Numbers from 1 to 20 Using

## To find the Square of the Numbers from 1 to 20 Using

Page 1 of 1## 3 Replies - 16046 Views - Last Post: 30 December 2008 - 04:50 AM

### #1

# To find the Square of the Numbers from 1 to 20 Using

Posted 29 December 2008 - 12:09 AM

##
**Replies To:** To find the Square of the Numbers from 1 to 20 Using

### #2

## Re: To find the Square of the Numbers from 1 to 20 Using

Posted 29 December 2008 - 12:13 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this:

Thanks.

Post your code like this:

Thanks.

### #3

## Re: To find the Square of the Numbers from 1 to 20 Using

Posted 29 December 2008 - 05:35 PM

From what it looks like, you're being asked to produce 4 programs using those different looping techniques to achieve the same goal - displaying squares of numbers up to 20.

The first step is working out the logic to this, if you can get down on paper in plain English (or

Now all you need to do is apply this using C++, which is pretty easy, let's take this for loop for example:

We're telling 'i' our number to start at 1 and then continue looping and adding 1 (increment) until we get to 10. This will print "Hello World!" ten times, it doesn't take much more fiddling to get this to multiply our number (i) by itself 20 times, which will be pretty much all you need for the for loop, I'll leave the rest to you

Good luck, buddy!

P.S: This is my first post on D.I.C

The first step is working out the logic to this, if you can get down on paper in plain English (or

*pseduocode*) exactly what you want to do, then you're halfway there! For example:number = 1 Start loop here while number is less than 20 print number times number (Square of number) Loop back Exit

Now all you need to do is apply this using C++, which is pretty easy, let's take this for loop for example:

for (i=1; i<=10; i++) { std::cout << "Hello world!\n"; }

We're telling 'i' our number to start at 1 and then continue looping and adding 1 (increment) until we get to 10. This will print "Hello World!" ten times, it doesn't take much more fiddling to get this to multiply our number (i) by itself 20 times, which will be pretty much all you need for the for loop, I'll leave the rest to you

Good luck, buddy!

P.S: This is my first post on D.I.C

This post has been edited by **Christopher Elison**: 29 December 2008 - 05:38 PM

### #4

## Re: To find the Square of the Numbers from 1 to 20 Using

Posted 30 December 2008 - 04:50 AM

And a good post it was. Very nice! Theory and explanatory examples without handing the exact solution.

Page 1 of 1