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
25 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
12 Likes
Related Questions
Give the output of the snippet:
int a=10,b=12; if(a>=10) a++; else ++b; System.out.println(a + "and" +b);
Predict the output:
int a=6,b=5,c; c = (a++ % b++) *a + ++a*b++;
Write a program to accept marks in Physics, Chemistry and Biology. The program calculates the average and displays the stream accordingly:
Average Marks Stream 80% and above Computer Science 60% or more but less than 80% Bio-Science 40% or more but less than 60% Commerce The Greatest Common Divisor (GCD) of two integers is calculated by the continued division method. Divide the larger number by the smaller, the remainder then divides the previous divisor. The process repeats unless the remainder reaches to zero. The last divisor results in GCD.
Sample Input: 45, 20
Sample Output: GCD=5