
while
Authored by Deepa Jagan
Education
KG
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In C, consider the behavior of a while loop when the condition involves a variable modified inside the loop body via undefined behavior (UB). Which statement is most accurate?
A) The loop will always terminate if the condition eventually becomes false
B) The compiler guarantees at least one evaluation of the loop condition before optimization
C) The loop behavior becomes unpredictable, and the compiler may optimize assuming UB never occurs
D) The loop executes exactly as written, since UB only affects runtime, not compilation
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
#include int main() {
int i = 0;
while (i++ < 3)
printf("%d ", i);
return 0;
}
1 2 3
1
2 3
0 1 2
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include int main() {
int i = 1;
while (i = 0) {
printf("Loop");
}
printf("Done");
}
Done
Loop Done
Loop
error
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
4 3 2 1 0
5 4 3 2 1
1 2 3 4 5
4 3 2 1
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which statement about evaluation order in while(condition) is correct?
A) The condition is evaluated once at compile time
B) The condition is evaluated before every iteration, including the first
C) The condition is evaluated after the loop body executes
D) The condition may be skipped if compiler optimizations apply
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Infinite loop printing 0
0 1 2 3 4 5
Compilation error
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
3
4
0
infinite loop
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?