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
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
Science,
5 months ago
India Languages,
5 months ago
English,
10 months ago
Math,
1 year ago
Science,
1 year ago