+ 2
29th Mar 2022, 3:01 PM
RAGHUKUMAR SURA
RAGHUKUMAR SURA - avatar
4 Respuestas
+ 1
Hi! The outer loop sets the bounderies, then the inner loop prints out all numbers up to the boundery: 1: 0 2: 0 1 3: 0 1 2 4: 0 1 2 3
29th Mar 2022, 3:23 PM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Yes, the while loop increases its output in every iteration of the for loop, and it depends on the value of the i variable in the for loop.
29th Mar 2022, 3:20 PM
Jan
Jan - avatar
+ 1
Thanks for your answers i got it
31st Mar 2022, 2:12 PM
RAGHUKUMAR SURA
RAGHUKUMAR SURA - avatar
0
let split the code to two section . outer . inner. outer is for loop . inner i the while loop. the inner loop does not effects the value of i . for (int i = 1; i < 5; i++) {... i get values 1 2 3 4 when i get 5 , it violate the condition i<5 therefor ending the outer loop for each i the inner loop is done . int j = 0; while (j < i) { System.out.print(j + " "); j++; }// while for every i , j start from 0 . so when i = 1 j get 0 and printed 0 then j=1 which ends inner loop when i=2 j get again 0 and also 1 then printed 0 1 then j=2 which ends inner loop when i=3 j get again 0 and also 1 2 then printed 0 1 2 then j=3 which ends inner loop when i=4 j get again 0 and also 1 2 3 then printed 0 1 2 3 then j=4 which ends inner loop when i=5 outer loop ends
30th Mar 2022, 5:08 PM
bluesky