Computer Applications
Give the output of the snippet:
int a = 3;
while (a<=10)
{
a++;
if(a== 5)
continue;
System.out.println(a);
}
Java
Java Iterative Stmts
21 Likes
Answer
4 6 7 8 9 10 11
Working
a | Sopln(a) | Remarks |
---|---|---|
3 | Initial value | |
4 | 4 | 1st Iteration |
5 | Not executed due to continue | 2nd Iteration |
6 | 6 | 3rd Iteration |
7 | 7 | 4th Iteration |
8 | 8 | 5th Iteration |
9 | 9 | 6th Iteration |
10 | 10 | 7th Iteration |
11 | 11 | 8th Iteration |
Loop stops as a is greater than 10 |
Answered By
9 Likes