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? int x = 10; while(x-- > 5) { printf("%d ", x); }
Which of the following statements about switch case is TRUE?
What will this code output? for(int i = 1; i <= 3; i++) { for(int j = 1; j <= i; j++) { printf("%d", j); } printf("\n"); }
What is the purpose of the ternary operator (? :) in C?
How many times will the loop execute? int i = 0; while(i++ < 5) { printf("%d ", i); }
What will be the output of this code? int n = 5; switch(n) { case 4: printf("Four"); case 5: printf("Five"); case 6: printf("Six"); break; default: printf("Other"); }
Which control structure would be most efficient to validate if a number is within one of several specific values?
What is the output? for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if(i == j) continue; printf("Done");
In C programming, what is the difference between break in a loop and break in a switch statement?
What will this code print? int x = 0; while(x < 3) { printf("%d ", x++); if(x == 2) continue; printf("X "); }
Which statement is true about the goto statement in modern C programming practices?
What will be printed? int i = 0, j = 0; for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { if(i + j == 2) break; printf("%d%d ", i, j); } }
What is the output of this code? char ch = 'B'; switch(ch) { case 'A': case 'B': case 'C': printf("Vowel"); break; default: printf("Consonant"); }
In a for loop with multiple break statements in different conditions, which break will be executed?
What is the primary difference between 'break' and 'continue' statements in C loops?
Consider the following code snippet: int x = 5; do { printf("%d ", x); x--; } while(x > 0); What will be the output?
In nested loops, if an inner loop contains a break statement, what happens?
Analyze this code: for(int i = 0; i < 5; i++) { if(i == 2) continue; if(i == 3) break; printf("%d ", i); } What is the output?
Which of the following statements about the switch-case construct is INCORRECT?
Consider the code: int sum = 0; for(int i = 1; i <= 10; i++) { if(i % 2 == 0) continue; sum += i; } printf("%d", sum); What will be printed?