Q: Which of the following loop control statements is used to skip the current iteration of a loop and continue with the next iteration?
A.continue
B.break
C.exit
D.return
Correct Option: AExplanation:
Answer: a) continue
Explanation: The continue statement is used to skip the current iteration of a loop and continue with the next iteration.
Q: Which loop control statement is used to exit from the loop and transfer control to the statement immediately after the loop?
A. break
B. continue
C. return
D. exit
Correct Option: AExplanation:
The "break" statement is used to terminate the loop and continue execution after the loop's closing brace.
Q: How many times the while loop will get executed if a short int is 2 byte wide?
#include
int main()
{
int j=1;
while(j <= 255)
{
printf("%c %d\n", j, j);
j++;
}
return 0;
}
A.Infinite times
B.255 times
C.256 times
D.254 times
Correct Option: AExplanation:
Option B
The while(j <= 255) loop will get executed 255 times. The size short int(2 byte wide) does not affect the while() loop.
Q: What happens if the loop condition is initially false in a do-while loop?
A. The loop executes once and terminates
B. The loop does not execute at all
C. The loop executes indefinitely
D. The loop executes but skips the first iteration
Correct Option: AExplanation:
In a do-while loop, the loop body is executed at least once even if the condition is initially false.
Q: Which of the following loop control statements is used to exit from a function or program?
A.continue
B.break
C.exit
D.return
Correct Option: CExplanation:
Answer: c) exit
Explanation: The exit statement is used to exit from a function or program.
Q: Which loop in C is used to execute a block of code at least once?
A. for loop
B. while loop
C. do-while loop
D. if-else loop
Correct Option: CExplanation:
The do-while loop executes the code block at least once before checking the loop condition. It is useful when you need to ensure the code block runs at least once.