C Programming - MCQ Practice Questions
Practice free C Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.
978 questions | 100% Free
What is the output of the following code? for(int i = 1; i <= 3; i++) { for(int j = 1; j <= 2; j++) { if(i == 2 && j == 1) break; printf("%d%d ", i, j); } }
In a nested loop, if we use 'goto' statement, where does the control transfer?
What is the output? int x = 5; switch(x) { case 5: printf("Five"); case 6: printf("Six"); default: printf("Default"); }
What will be printed? for(int i = 0; i < 3; i++) { if(i == 1) goto skip; printf("%d ", i); } skip: printf("End");
Analyze the code: What happens when condition in if statement is false? if(0) { statements; } else { statements; }
What is the final value of x? int x = 0; for(int i = 1; i <= 5; i++) { if(i % 2 == 0) continue; x += i; }
In the ternary operator (? :), what happens if the condition is false?
What will be the result? for(int i = 1; i <= 4; i++) { if(i == 3) break; printf("%d ", i); }
In a switch statement with integer cases, can a case have a floating-point constant?
What is printed by this code? int x = 1, y = 2; if(x > y) printf("A"); else if(x < y) printf("B"); else printf("C");
What happens with this nested if? if(1) if(0) printf("A"); else printf("B");
Predict the output: for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) if(i + j == 1) continue; printf("Done");
What is the behavior of this code? int i = 0; while(1) { i++; if(i > 5) break; }
Which statement best describes the difference between break and continue?
What value does the ternary operator return? int result = (5 > 3) ? 10 : 20;
What is the output of this complex nested loop? for(int i = 1; i <= 2; i++) { for(int j = 1; j <= 2; j++) { if(i == j) continue; printf("%d%d ", i, j); } }
Which of the following control flow statements will cause a compilation error in C?
What is the primary difference between while and do-while loops?
In a switch statement, if a case label is missing the break statement, what occurs?
Which control flow statement allows jumping to a labeled location in C?