How many times will a 'do-while' loop execute its body if the condition is initially false in C?
A. 0 times
B. 1 time
C. Infinite times
D. It depends on the loop body
Answer: Option B
Solution(By Examveda Team)
In C, ado-while
loop executes its body at least once, even if the condition is initially false. This is because the condition is evaluated after the body of the loop has been executed. If the condition is false after the first execution of the body, the loop terminates. Therefore, even if the condition is initially false, the loop body will execute once before the condition is evaluated.So, the correct answer is Option B: 1 time.
Join The Discussion
Comments ( 1 )
Related Questions on Control Structures
Which control structure is used to repeatedly execute a block of code in C?
A. for loop
B. if statement
C. switch case
D. while loop
In C, what is the purpose of the 'break' statement within a loop?
A. Continue to the next iteration
B. Exit the program
C. Terminate the loop and exit it
D. Skip the current iteration
What is the purpose of the 'else' statement in C's 'if-else' control structure?
A. Execute the 'if' block
B. Execute the 'else' block
C. Execute both 'if' and 'else' blocks
D. Skip the 'if' block
Which control structure is used to make a decision between two or more alternatives in C?
A. switch case
B. for loop
C. if statement
D. while loop
i think the code will execute once