Computer Science, asked by chai2601, 10 months ago

what will be the output for

int m= 5;

for(n=1 ; n<= m; n++,m--)

System.out.println(n);

System.out.println(m);​

Answers

Answered by shwbd0117
1

Answer: n=4 and m=2

Explanation:This is because when the loop is traversed for the first time value of n will become 2 and m will become 4, then second time it be such that n will be 3 and m will be 3. But as the condition is n<=m it will execute once more and n will become 4 and m will become 2 now the loop will terminate.

Similar questions