# looping, for,while,do-while.

• August 6th, 2009, 05:53 AM
chronoz13
looping, for,while,do-while.
can anyone please do this problem

1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16

in for loop, while loop, and do-while,,

ill study how this works in these three different structures of loop

tnx a lot!!
• August 6th, 2009, 06:28 AM
JavaPF
Re: looping, for,while,do-while.
Hello chronoz13.

I'm a bit confused... Can you please give me a little more detail?
• August 6th, 2009, 09:56 AM
chronoz13
Re: looping, for,while,do-while.
oh sori sir..

i've just red it on my school mate a while ago.

it says

do that program by using a loop(i dont remember all the details)

but i think that

the first number (number 1) will be initialized then it will increment up to (4). (THE FIRST ROW)

1 2 3 4

but im having some trouble formulating the idea on how to loop the next numbers ,(2nd 3rd and 4th row)

2 4 6 8
3 6 9 12
4 8 12 16
• August 6th, 2009, 01:28 PM
JavaPF
Re: looping, for,while,do-while.
Are all these loops ment to be together as one or are you look for an example answer for each loop?
• August 6th, 2009, 01:32 PM
Json
Re: looping, for,while,do-while.
Code :

``` for(int i = 1; i <= 4; ++i) { System.out.print(i + " "); }   System.out.println("");   for(int i = 2; i <= 8; i += 2) { System.out.print(i + " "); }   System.out.println("");   for(int i = 3; i <= 12; i += 3) { System.out.print(i + " "); }   System.out.println("");   for(int i = 4; i <= 16; i += 4) { System.out.print(i + " "); }```

That should print what you want I guess.

1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16

// Json