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
Consider a scenario where you need to store a variable that can hold values up to 10 billion. Which data type is most suitable?
What happens when a volatile variable is declared in a multi-threaded C program?
In C programming, when you declare a variable as 'const int x = 5;', what happens if you try to modify it within the program?
What will be the output of the following C code? int x = 5; if (x > 3) printf("A"); else printf("B");
Which of the following is NOT a valid control flow statement in C?
What is the output of this code? for (int i = 0; i < 3; i++) printf("%d ", i);
What is the difference between 'break' and 'continue' in loops?
What will be printed? int x = 0; if (x = 5) printf("True"); else printf("False");
What is the output? for (int i = 1; i <= 5; i++) { if (i == 3) break; printf("%d ", i); }
What does the following nested if-else produce? int a = 10, b = 20; if (a > b) if (b > 0) printf("X"); else printf("Y");
What is the output of this switch statement? int x = 2; switch(x) { case 1: printf("One"); break; case 2: printf("Two"); case 3: printf("Three"); break; default: printf("Other"); }
How many times will this loop execute? for (int i = 0; i < 5; ++i) { if (i == 2) continue; if (i == 4) break; }
What is printed by this code? int x = 5; while (x-- > 0) printf("%d ", x);
What is the output? int n = 1; do { printf("%d ", n); n++; } while (n > 5);
Analyze the ternary operator: int x = (5 > 3) ? 10 : 20; What is the value of x?
What is the output of this program? for (int i = 1; i <= 3; i++) for (int j = 1; j <= 2; j++) printf("%d", i*j); printf("\n");
What is the behavior of goto in C?
Determine the output: int i = 0; while (i < 3) { printf("%d ", i++); }
What does this code segment output? for (int i = 0; i < 5; i++) { if (i % 2 == 0) continue; printf("%d ", i); }
Which statement is used to skip remaining iterations and move to next iteration?