0
what will display the following program item and how many times will be executed the loop
int x = 7; int z; for(z = 1; z <= 6; z++) x = x+z; x = x * 10; System.out.println("x = " + x); System.out.println("z = " + z);
3 ответов
+ 12
code is correct syntax wise, what problem you are facing in it ?
if its about output, then x will be (7 + (1+2+3+4+5+6))*10 & z will be 7, as only 1 statement is consider to in loop block if no { } are made after loop.
+ 11
loop will execute 6 times, and only 1 statement will get executed multiple times, that statement is x=x+z;
loop will end when z becomes 7, so final value of z will be 7.
+ 1
thank you!