Give output of the following Java code:
for(int i = 10; i >= 1; i -- )
{
}
System.out.print( i + "," );
}
System.out.println( i );
Answers
Answered by
0
brackets issue in the question
the code can't be generated
Answered by
6
Answer:
10,9,8,7,6,5,4,3,2,1,
0
Explanation:
*Even though there is bracket error it should be:
for(int i=10;i>=1;i--){
S. o. p(i+ " ");
}
S. o. pln(i);
So, using this logic the loop is a reverse loop and runs till i either greater than Or equal to 1 so;
'i' keeps decreasing till it reaches 1,now after i becomes 0 due to decrement operator the loop terminates as the condition is false which is (0!>=1)
(!=not) therefore comes out of the loop body and prints the S.o.pln statement outside the loop where i=0;
and thus prints 0 in the corresponding next line.
Hope it helps you.
If it did mark it brainliest...(Thanks)
Adieu,
Similar questions