|1||Break example output|
|2||Nested For loop output63|
|3||For sample program output65|
|4||Print numbers using while and break|
|5||Print numbers using while and break95|
|6||Calculate sum of numbers using while and break|
|7||Find Square Root Of Number|
|8||Print Season depending upon the month|
|9||Program To Assign Hostel Block|
|10||Print multiplication table until the product is less than 100|
|11||Do while output|
What will be the output of the following program?
Correct Answer : B
Execution of program starts from
main three integer variables called
count are declared and are initialized to
10 respectively. The next statement is a
while loop with condition
n <= 3. As long as this condition is satisfied
while loop is executed.
sum is added to
n * 2 and
count is decremented everytime. When
if condition is satisfied and the loop breaks. The value of
n in program also keeps changing. It gets incremented everytime. Thus
sum will always be changing and then finally it ends up with the value
12 (= 0 * 2 + 1 * 2 + 2 * 2 + 3 * 2 = 0 + 2 + 4 + 6).
Hence, The answer is B.