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 does this code segment output? for (int i = 0; i < 5; i++) { if (i % 2 == 0) continue; printf("%d ", i); }
Which of the following is NOT a valid use of the goto statement in C?
Consider a switch statement with multiple cases. If a case matches and break is omitted, what happens?
What will be the behavior of a for loop with an empty body and no statements inside braces?
What is the output of executing break in a nested loop context?
Which of the following correctly uses the conditional (ternary) operator?
How many times will a do-while loop execute if the condition is initially false?
In control flow, which statement is used to explicitly exit from a program?
In a switch statement, case values must be of which type?
What is the scope of a variable declared in the initialization section of a for loop?
Which statement is best suited for implementing a menu-driven program with exact matching?
What will be the output of the following code? int i = 0; while(i < 3) { printf("%d ", i++); if(i == 2) continue; }
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");
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 a switch statement with integer cases, can a case have a floating-point constant?
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");