Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## For Statement

Code:
```import java.io.*;

public class For

{
public static void main (String [] args)

{
int x;

for(x=0;x<3;x++)  {

System.out.println(x);

/*
----------------------------------------------------
the SEQUENCE the computer reads the FOR statement
----------------------------------------------------
1.x=0
2.x<3
3.System.out.println(x);
4.x++
5.x<3
6.System.out.println(x);
7.x++
8.x<3
9.System.out.println(x);
10.x++
11.x<3
12.EXIT

-------
OUTPUT
-------
0
1
2

*/

}
}
}```
A.)
I know how a single for statement works (see above) a help for those who doesnt know single FOR statement for newbies like me

Now Im confused in how three nested FOR statement works. Can you please show me the sequence of a 3 nested IF statement.

Code:
``` int x,y,z;

for(x=0;x<2;x++)  {
System.out.println(x+ "A");
for(y=0;y<2;y++)  {
System.out.println(y+ "B");
for(y=0;y<2;y++)  {
System.out.println(y+ "C");

}
}
}```

• I'm confused. You're asking about showing how three nested If statements would work, but your code shows three "for" loops. Which are you looking for, nested If's, or nested For loops?

I'm confused. You're asking about showing how three nested If statements would work, but your code shows three "for" loops. Which are you looking for, nested If's, or nested For loops?
Sorry bro i mistyped the nested If statements.

It should have been nested 3 FOR statement

I edited the first post thanks kadams

• Code:
```for(x=0;x<2;x++)  {
System.out.println(x+ "A");
for(y=0;y<2;y++)  {
System.out.println(y+ "B");
for(`z`=0;`z<2;z++`)  {
System.out.println(`z+` "C");

}
}
}```
1. x=0
2. System.out.println(0+ "A");
1. y=0
2. System.out.println(0+ "B");
1. z=0
2. System.out.println(0+ "C");
3. z=1
4. System.out.println(1+ "C");
5. z=2
6. System.out.println(2+ "C");

3. y=1
4. System.out.println(1+ "B");
1. z=0
2. System.out.println(0+ "C");
3. z=1
4. System.out.println(1+ "C");
5. z=2
6. System.out.println(2+ "C");

.............
3. x=1
4. System.out.println(1+ "A");
...............
Lol, I learned some BBCode

• Originally Posted by abduraooft
Code:
```for(x=0;x<2;x++)  {
System.out.println(x+ "A");
for(y=0;y<2;y++)  {
System.out.println(y+ "B");
for(`z`=0;`z<2;z++`)  {
System.out.println(`z+` "C");

}
}
}```
1. x=0
2. System.out.println(0+ "A");
1. y=0
2. System.out.println(0+ "B");
1. z=0
2. System.out.println(0+ "C");
3. z=1
4. System.out.println(1+ "C");
5. z=2
6. System.out.println(2+ "C");

3. y=1
4. System.out.println(1+ "B");
1. z=0
2. System.out.println(0+ "C");
3. z=1
4. System.out.println(1+ "C");
5. z=2
6. System.out.println(2+ "C");

.............
3. x=1
4. System.out.println(1+ "A");
...............
Lol, I learned some BBCode
Hey thanks for the answer.. but Im still confused..

Can you please or someone arrange the SEQUENCE the computer reads the FOR statement. The previous answer was hopping statements like (x>2) or (z++). Im confused.. thanks

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•