...
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023

Programming-for-Output-Problems

Question 13

What is the output of the following C code?

#include

int main()

{

int index;

for(index=1; index<=5; index++)

{

printf(“%d”, index);

if (index==3)

continue;

}

}

A
1245
B
12345
C
12245
D
12354
Question 13 Explanation: 
The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
In the given code, there are no statements after continue statement , So it won’t effect on the output.
The loop will executes for five iterations,For each iteration it will print corresponding value i.e; 12345.
Correct Answer: B
Question 13 Explanation: 
The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
In the given code, there are no statements after continue statement , So it won’t effect on the output.
The loop will executes for five iterations,For each iteration it will print corresponding value i.e; 12345.

Leave a Reply

Your email address will not be published. Required fields are marked *