+ 2

I dont understand what happends when theres 2 for loops inside 1 statement can anyone explain? I tried to work it out but still.

for(int x = 1; // value of x = 1 x<=5; // 1 less or equal to 5 is true x++) // increment 1 before prefix { for(int y = 1; // value of x = 1 y<=x; // 1 less or equal to 1 true y++) // increment 1 before prefix { System.out.print("*"); } System.out.println(); }

9th Aug 2017, 11:46 AM
D_Stark
D_Stark - avatar
5 Respostas
+ 3
when inner loop completes a cycle the value In outerloop changes until until the outerloop reaches its limits
9th Aug 2017, 11:49 AM
Ali Ahmed Shaikh
Ali Ahmed Shaikh - avatar
+ 2
thanks thats easier to understand
9th Aug 2017, 1:11 PM
D_Stark
D_Stark - avatar
+ 1
ali said the answer which is correct as i underatand it now.
14th Aug 2017, 8:42 PM
D_Stark
D_Stark - avatar
0
Are that conditions x=1,y<=x hold at the same time?If it is,you can try “x=1 and x<=y”. If I'm mistaken,Please guide,thanks!
10th Aug 2017, 7:23 AM
coolbreeze
0
i got confused
14th Aug 2017, 8:32 PM
Abdifatah Mohamed
Abdifatah Mohamed - avatar