What values will be printed when the loop is executed. If loopis illegal or prod
ID: 3615304 • Letter: W
Question
What values will be printed when the loop is executed. If loopis illegal or produces no output, provide the information as youranswer. Assume that all variables have integer types and havealready declared.a) ADA
N := 10; for I in reverse 1..N loop Put_Line (I); N := N-1; end loop
b) JAVA
for (int i = 0; j = 10; i < 2 * j; i++, j--) system.out.println(i);
a) ADA
N := 10; for I in reverse 1..N loop Put_Line (I); N := N-1; end loop
b) JAVA
for (int i = 0; j = 10; i < 2 * j; i++, j--) system.out.println(i);
Explanation / Answer
N := 10; for I in reverse 1..N loop Put_Line (I); N := N-1; end loop I don't know Ada but I do know languages, so an educated guesswould say10
9
8
7
6
5
4
3
2
1
b) JAVA
for (int i = 0, j = 10; i < 2 * j; i++,j--) trace i j
system.out.println(i); 0 10 i<20?
0 1 9 i<18?
1 2 8 i<16?
2 3 7 i<14?
3 4 6 i<12?
4 5 5 i<10?
5 6 4 i<8?
6 7 3 i<6? no exit