Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## 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!!

2. ## Re: looping, for,while,do-while.

Hello chronoz13.

I'm a bit confused... Can you please give me a little more detail?

3. ## 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

4. ## 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?

5. ## Re: looping, for,while,do-while.

```    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