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 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); } }
What is the output of: for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) if(i == j) continue; printf("Done");
What will this code do? int i = 0; while(i < 5) { printf("%d ", i++); if(i == 3) break; }
Which statement best describes the 'dangling else' problem in C?
What is the output? for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if(i == j) continue; printf("Done");
What will this code print? int x = 0; while(x < 3) { printf("%d ", x++); if(x == 2) continue; printf("X "); }
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); } }
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?
How can you modify a variable inside a function and reflect the change in the calling function?
What is the output of this code? int* getPointer(int *p) { return p; } int main() { int a = 10; int *ptr = getPointer(&a); printf("%d", *ptr); }
What are static local variables in functions used for?
What will be the output? int counter() { static int count = 0; return ++count; } int main() { printf("%d ", counter()); printf("%d ", counter()); printf("%d", counter()); }
Which of the following is TRUE about inline functions in C99 standard?
What is function overloading in the context of C?
In C99 and later standards, what is the maximum number of parameters a function can have?
What is the primary advantage of using function pointers in C?
How does the volatile keyword affect function behavior in C?
What will happen if a recursive function has no base case?
Consider mutual recursion: void funcA(int n); void funcB(int n); funcA calls funcB and vice versa. What is required?
What is the correct way to return multiple values from a function in C?