--:--









Quiz for for, while, do-while

Course: C Language | Subject: Unit 3 | Topic: Control Statements



Logo

Q1: Which loop is best suited when the number of iterations is known beforehand?

Logo

Q2: Which loop will always execute its body at least once?

Logo

Q3: What is the output of: int i=0; while(i<3){printf("%d",i); i++;}?

Logo

Q4: Which loop is entry-controlled?

Logo

Q5: What is wrong with: for(;;) { /* code */ }?

Logo

Q6: Which loop is most suitable for reading input until EOF?

Logo

Q7: How many times will do{ printf("Hi"); }while(0); print "Hi"?

Logo

Q8: Which of the following is valid syntax for a for loop?

Logo

Q9: Which loop can be replaced by the other two without changing functionality?

Logo

Q10: What is the output of: for(int i=0;i<3;i++) printf("%d",i);?

Logo

Q11: Which loop is typically faster in execution?

Logo

Q12: What does while(1) represent?

Logo

Q13: Can we initialize multiple variables in a for loop?

Logo

Q14: What is the default increment step in a for loop if not specified?

Logo

Q15: Which loop is better when body needs to run before checking condition?

Logo

Q16: Is it valid: while(x=5) { ... }?

Logo

Q17: What is the output of: int i=1; do{printf("%d",i);}while(i++<3);?

Logo

Q18: What is a common use of an empty for loop?

Logo

Q19: Which statement can be used to terminate a loop prematurely?

Logo

Q20: Which statement skips the current iteration and continues with the next?

Are you ready to start test? Set your time limit