MCQOPTIONS
Saved Bookmarks
This section includes 49 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 1; switch (n) { case n: printf("Case N "); default: printf("Default"); } } |
| A. | Compilation Error |
| B. | Case N |
| C. | Default |
| D. | All of above |
| E. | None of these |
| Answer» B. Case N | |
| 2. |
Which of the following statement are correct about the program given below?#include <stdio.h>int main ( ){ int x = 10, y = 20; if (x == 15) && if (y == 20) printf ("Have a nice day n"); return 0;} |
| A. | Output: Have a nice day |
| B. | No output |
| C. | Error: 'Expression syntax' |
| D. | Error: 'Undeclared identifier if' |
| Answer» D. Error: 'Undeclared identifier if' | |
| 3. |
Which of the following statement are correct about the program given below?#include <stdio.h>int main ( ){ int a = 40, b = 50; if ( a == b ) printf ("a is equal to b n"); elseif (a > b) printf ("a is greater than b n"); elseif (a < b) printf ("a is less than b n"); return 0;} |
| A. | Error: 'elseif is not a keyword in C' |
| B. | Error: 'Expression syntax' |
| C. | Error: 'L value required' |
| D. | Error: 'R value requaired' |
| Answer» B. Error: 'Expression syntax' | |
| 4. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main (){ int a = 400, b, c; if ( a >= 500) b = 400; c = 300; printf ( "%d %d %d n" , a, b, c); return 0;} |
| A. | 400 400 300 |
| B. | Garbage 400 300 |
| C. | 400 Garbage 300 |
| D. | 400 400 Garbage` |
| Answer» D. 400 400 Garbage` | |
| 5. |
Which of the following is the correct output for the program given below ?#include <stdio.h>int main ( ){ int k = 5; switch (k) { case 1: printf ("Good Morning n"); case 2: printf ("Good Evening n"); break; case 3: continue; default: printf ("Bye n"); } return 0;} |
| A. | Error: 'Misplaced Continue' |
| B. | Bye |
| C. | No output |
| D. | Good Morning |
| E. | Good Evening |
| Answer» B. Bye | |
| 6. |
Which of the following cannot be checked in a switch - case statement? |
| A. | Character |
| B. | Integer |
| C. | Float |
| D. | enum |
| Answer» D. enum | |
| 7. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input).#include <stdio.h> void main() { char *n; printf("Enter a value between 1 to 3:"); scanf("%s", n); switch (n) { case "1": printf("Hey"); break; case "2": printf("Hello"); break; } } |
| A. | Hey |
| B. | Hellow |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 8. |
Comment on the output of the following C code. #include <stdio.h> int main() { int num = 2; switch (num) case 1: printf("%d", num); case 2: printf("%d", num); case 3: printf("%d", num); default: printf("%d", num); } |
| A. | No error, output is 2 |
| B. | Compile time error, case label outside switch statement |
| C. | No error, output is 2222 |
| D. | Compile time error, no break statements |
| E. | None of these |
| Answer» C. No error, output is 2222 | |
| 9. |
What will be the output of the following C code?#include <stdio.h> #define max(p) p int main() { int n = 1; switch (n) { case max(2): printf("Right... n"); case max(1): printf("Wrong... n"); break; } } |
| A. | Right... |
| B. | Wrong... |
| C. | Right... Wrong... |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 10. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input).#include <stdio.h> void main() { double var; printf("Enter a value between 1 to 2:"); scanf("%lf", &var); switch (var) { case 1: printf("1"); break; case 2: printf("2"); break; } } |
| A. | 1 |
| B. | Compilation Error |
| C. | 2 |
| D. | Runtime Error |
| E. | None of these |
| Answer» C. 2 | |
| 11. |
What will be the output of the following C code? #include <stdio.h> int main() { if (printf("%d", printf("))) printf("I am Sad..."); else if (printf("1")) printf("I am Happy..."); } |
| A. | Runtime Error |
| B. | I am Sad... |
| C. | I am Happy... |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 12. |
What will be the output of the following C code? #include <stdio.h> const int n = 10, m = 12; int main() { int P = 10; switch (P) { case n: printf("Yes..."); case m: printf("No... n"); break; } } |
| A. | Yes... |
| B. | No... |
| C. | Yes... No... |
| D. | Runtime Error |
| E. | Compilation Error |
| Answer» D. Runtime Error | |
| 13. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 98; switch (n) { case 'b': printf("Right... "); break; case 98: printf("Wrong... n"); break; } } |
| A. | Character case value error |
| B. | Right... |
| C. | Wrong... |
| D. | Duplicate case value error |
| E. | None of these |
| Answer» E. None of these | |
| 14. |
What will be the output of the following C code?#include <stdio.h> int main() { float n = 12; switch (n) { case 1.0: printf("Option: First n"); break; default: printf("Option: Default n"); } } |
| A. | 12 |
| B. | Option: First |
| C. | Option: Default |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 15. |
What will be the output of the following C code? (Assuming that we have entered the value 3 in the standard input).#include <stdio.h> int main() { int num; printf("Enter a value between 1 to 2:"); scanf("%d", &num); switch (num) { case 1: printf("Hey... n"); default: printf("Hello... n"); } } |
| A. | Runtime Error |
| B. | Compilatin Error |
| C. | Hey... |
| D. | Hello... |
| E. | None of these |
| Answer» E. None of these | |
| 16. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 10, m = 10; switch (n) { case n*m: printf("True "); case n-m: printf("False n"); break; } } |
| A. | 10 |
| B. | Compilation Error |
| C. | 10 |
| D. | True |
| E. | False |
| Answer» C. 10 | |
| 17. |
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input).#include <stdio.h> int main() { int var; printf("Enter a value between 1 to 2: "); scanf("%d", &var); switch (var, var + 1) { case 1: printf("Option 1."); break; case 2: printf("Option 2."); break; default : printf("Default option."); } } |
| A. | Option 1. |
| B. | Option 2. |
| C. | Default option. |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 18. |
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input).#include <stdio.h> int main() { int p; printf("Enter a value between 1 to 2:"); scanf("%d", &p); switch (p) { case 1: printf("hey... n"); break; printf("Hello..."); default: printf("How are U? n"); } } |
| A. | Hey... |
| B. | Hello... |
| C. | How are U? |
| D. | All of above |
| E. | None of these |
| Answer» D. All of above | |
| 19. |
What will be the output of the following C code? #include <stdio.h> int main() { int n = 1; if (n) printf("Everything is okay."); printf("Everything is not okay. n"); else printf("I have fever n"); } |
| A. | Everything is okay. |
| B. | Everything is not okay. |
| C. | I have fever. |
| D. | Compilation Error |
| E. | Runtime Error |
| Answer» E. Runtime Error | |
| 20. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 1; if (n--) printf("Right..."); if (n++) printf("Wrong..."); } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | Right... |
| D. | Wrong... |
| E. | None of these |
| Answer» D. Wrong... | |
| 21. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 0; if (n == 1) if (n >= 0) printf("True... n"); else printf("False... n"); } |
| A. | Compilation Error |
| B. | False... |
| C. | True... |
| D. | It will print nothing. |
| E. | None of these |
| Answer» E. None of these | |
| 22. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 5; if (n == 5) printf("True, "); else if (n = 20) printf("False, "); printf("%d n", n); } |
| A. | False, 20 |
| B. | 20, False |
| C. | 5, True |
| D. | True, 5 |
| E. | None of these |
| Answer» E. None of these | |
| 23. |
What will be the output of the following C code?#include <stdio.h> int main() { int p = 0; if (p == 1) if (p == 0) printf("Inside if block executed... n"); else printf("Inside else if block executed... n"); else printf("Inside else block executed... n"); } |
| A. | Inside else block executed... |
| B. | Inside if block executed... |
| C. | Inside else if block executed... |
| D. | Compilation Error |
| E. | None of these |
| Answer» B. Inside if block executed... | |
| 24. |
What will be the output of the following C code?#include <stdio.h< int n; void main() { if (n) printf("Hey"); else printf("How are u?"); } |
| A. | Compilation Error |
| B. | Hey |
| C. | How are u? |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 25. |
What will be the output of the following C code?#include <stdio.h> void main() { int num = 6; if (num < 2) printf("Hello"); if (num == 6) printf("Hey"); else printf("No"); } |
| A. | 6 |
| B. | Hey |
| C. | Hello |
| D. | No |
| E. | None of these |
| Answer» C. Hello | |
| 26. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)#include <stdio.h> void main() { char *name; printf("Enter a value between 1 to 3:"); scanf("%s", name); switch (name) { case "1": printf("1"); break; case "2": printf("2"); break; } } |
| A. | name |
| B. | 1 |
| C. | 2 |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 27. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)#include <stdio.h> void main() { double n; printf("Enter a value between 1 to 2:"); scanf("%lf", &n); switch (n) { case 1: printf("1"); break; case 2: printf("2"); break; } } |
| A. | 1 |
| B. | 2 |
| C. | Garbage value |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 28. |
What will be the output of the following C code? #include <stdio.h> void main() { int p = 15; if (true); printf("Hey... Hellow..."); } |
| A. | Hey.. |
| B. | Hellow... |
| C. | 15 |
| D. | true |
| E. | Compilation Error |
| Answer» F. | |
| 29. |
What will be the output of the following C code? #include <stdio.h> void main() { int p = 6; if (p < 2); printf("Hey..."); } |
| A. | 2 |
| B. | 6 |
| C. | Compilation Error |
| D. | Hello |
| E. | None of these |
| Answer» E. None of these | |
| 30. |
What will be the output of the following C code?#include <stdio.h> void main() { int n = 2; if (n == 2) printf("Hey "); else printf("How are u? "); printf("Hello "); } |
| A. | Hey |
| B. | Hello |
| C. | Hey Hello |
| D. | Hey Hello How are u? |
| E. | Hey How are u? Hello |
| Answer» D. Hey Hello How are u? | |
| 31. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 1; if (n++) printf("True n"); else if (n == 2) printf("False n"); } |
| A. | True |
| B. | False |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» B. False | |
| 32. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 5; if (n > 1) printf("Inside if block executed... n"); else if (n > 1) printf("Inside else if block executed... n"); } |
| A. | Compilation Error |
| B. | Inside if block executed... |
| C. | Inside else if block executed... |
| D. | Runtime Error |
| E. | None of these |
| Answer» C. Inside else if block executed... | |
| 33. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)#include <stdio.h> void main() { int n; printf("Enter a value between 1 to 2:"); scanf("%d", &n); switch (n, n + 1) { case 1: printf("1 n"); break; case 2: printf("2"); break; } } |
| A. | Compilation Error |
| B. | 1 |
| C. | Runtime Error |
| D. | 2 |
| E. | None of these |
| Answer» E. None of these | |
| 34. |
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input) #include <stdio.h> void main() { int num; printf("Enter a value between 1 to 2:"); scanf("%d", &num); switch (num) { case 1: printf("1 n"); break; printf("Hey..."); default: printf("2 n"); } } |
| A. | 1 |
| B. | Hey... |
| C. | 2 |
| D. | Compilation Error |
| E. | Runtime Error |
| Answer» D. Compilation Error | |
| 35. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)#include <stdio.h> void main() { int var; printf("Enter a value between 1 to 2:"); scanf("%d", &var); switch (var) { case 1: printf("1 n"); default: printf("2 n"); } } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | 1 |
| D. | 1 2 |
| E. | 2 |
| Answer» E. 2 | |
| 36. |
Which of the following statements are correct about the program given below?#include <stdio.h>int main ( ) { int a = 0, b = 1; b == 1 ? (a = 0) : (a = 1); if (a) printf ("YES n"); else printf ("No n"); return 0;} |
| A. | Error: 'Declaration terminated incorrectly' |
| B. | Error: 'Syntax error' |
| C. | Error: 'Lvalue required' |
| D. | Error: 'Expression syntax' |
| E. | The program works correctly without error. |
| Answer» F. | |
| 37. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ int a = 5; float b = 5.0; if (a == b) printf (" a and b are equal n"); else printf ("a and b are not equal n"); return 0;} |
| A. | a and b are equal |
| B. | a and b are not equal |
| C. | Unpredictable |
| D. | No output |
| Answer» B. a and b are not equal | |
| 38. |
Which of the following statements are correct about the following program?#include <stdio.h>int main ( ){ int a = 20, b = 30; if (a % 2 = b % 3) printf (" n Carpathians"); return 0;} |
| A. | Error : 'Expression syntax' |
| B. | Error : 'L value required' |
| C. | Error : 'R value required' |
| D. | The code runs successfully. |
| Answer» C. Error : 'R value required' | |
| 39. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ int x = 0, y = 1, z = 3; * ( ( x ) ? &y : &x = x ? y :z; printf ("%d %d %d n", x, y, z); return 0;} |
| A. | 0 1 3 |
| B. | 1 2 3 |
| C. | 3 1 3 |
| D. | 1 3 1 |
| Answer» D. 1 3 1 | |
| 40. |
Which of the following is the correct output for the program given below ?#include <studio.h>int main ( ){ char ch; if ((ch = printf (""))); printf ("I am inside if n"); else printf ("I am inside else n"); return 0;} |
| A. | I am inside if |
| B. | I am inside else |
| C. | random value |
| D. | No Output |
| Answer» C. random value | |
| 41. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ int x = 600, y = 200, z; if (!x >= 400) y = 300; z = 450; printf ("y = %d z = %d n", y, z); return 0;} |
| A. | y = 300 z = 200 |
| B. | y = 200 z = garbage |
| C. | y = 300 z = garbage |
| D. | y = 200 z = 450 |
| E. | y = 200 z = 600 |
| Answer» E. y = 200 z = 600 | |
| 42. |
Which of the following is the correct output for the program given below ?#include <stdio.h>int main (){ int k, number = 50; k = (number >10 ? (number <= 70 ? 220 : 710) : 650); printf ("%d n", k); return 0;} |
| A. | 220 |
| B. | 50 |
| C. | 710 |
| D. | 650 |
| Answer» B. 50 | |
| 43. |
Which of the following is the correct output for the program given below?#include <studio.h>int main(){ int a = 50, b = 60; if(!(!a) &&a) printf("a = %d n",a)' else printf("b = %d n",b); return 0;} |
| A. | b = 60 |
| B. | a = 0 |
| C. | a = 50 |
| D. | a = 1 |
| Answer» D. a = 1 | |
| 44. |
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input) |
| A. | 1 |
| B. | Hey... |
| C. | 2 |
| D. | Compilation Error |
| E. | Runtime Error |
| Answer» D. Compilation Error | |
| 45. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input) |
| A. | Compilation Error |
| B. | 1 |
| C. | Runtime Error |
| D. | 2 |
| E. | None of these |
| Answer» E. None of these | |
| 46. |
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input). |
| A. | Hey |
| B. | Hellow |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 47. |
What will be the output of the following C code? (Assuming that we have entered the value 3 in the standard input). |
| A. | Runtime Error |
| B. | Compilatin Error |
| C. | Hey... |
| D. | Hello... |
| E. | None of these |
| Answer» E. None of these | |
| 48. |
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input). |
| A. | Option 1. |
| B. | Option 2. |
| C. | Default option. |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 49. |
Which of the following cannot be checked in a |
| A. | Character |
| B. | Integer |
| C. | Float |
| D. | enum |
| Answer» D. enum | |