MCQOPTIONS
Saved Bookmarks
This section includes 98 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 would be the output of following program ?int x = 15;main(){ int x = 60; print(" n%d", x);} |
| A. | Error |
| B. | 15 |
| C. | 60 |
| D. | Garbage value |
| Answer» D. Garbage value | |
| 2. |
Which of the following is the correct output for the program given below?#include <studio.h>int main(){ extern int x; x = 30; printf("%d n", sizeof(x)); return 0;} |
| A. | 2 |
| B. | 4 |
| C. | Would vary from compiler to compiler |
| D. | Error, x undefined |
| Answer» E. | |
| 3. |
Which of the following is the correct output for the program given below?#include <studio.h>int main(){ extern int k; printf("%d n", k ); return 0;}int k = 30; |
| A. | 30 |
| B. | 0 |
| C. | Garbage value |
| D. | Error |
| Answer» B. 0 | |
| 4. |
Which of the following is the correct output for the program given below ?#include <studio.h>int main(){ extern int fun (float); int k; k = fun (5.74); printf ("%d n", k); return 0;} int fun (kk)float kk; { return ((int) kk); } |
| A. | 3 |
| B. | 5.74 |
| C. | 0 |
| D. | Error |
| Answer» E. | |
| 5. |
What will be the output of the following C code?#include <stdio.h> void fun(const int *); int main() { const int k = 12; printf("%d ", k); fun(&k); printf("%d", k); } void fun(const int *k) { *k = 21; } |
| A. | 12 21 |
| B. | 21 12 |
| C. | Runtime Error |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 6. |
What will be the output of the following C code? #include <stdio.h> int main() { int Eighteen = 18; int eighteen = 15; printf("%d", eighteen); return 0; } |
| A. | 18 |
| B. | Compilation Error |
| C. | 15 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 7. |
Will the following C code compile without any error?#include <stdio.h> int main() { int n; { int n; for (n = 0; n < 12; n++); } } |
| A. | No |
| B. | Yes |
| C. | Depends on the C standard implemented by compilers |
| D. | All of above |
| E. | None of these |
| Answer» C. Depends on the C standard implemented by compilers | |
| 8. |
What will be the output of the following C code? #include <stdio.h> int main() { k = 23; printf("%d n", k++); return 0; } |
| A. | 21 |
| B. | 22 |
| C. | 23 |
| D. | 24 |
| E. | Compilation Error |
| Answer» F. | |
| 9. |
What will be the output of the following C code?#include <stdio.h> int main() { const int k = 11; int *p = &k; *p = 22; printf("%d n", k); return 0; } |
| A. | 11 |
| B. | Compilation Error |
| C. | 22 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 10. |
What will be the output of the following C code?#include <stdio.h> void main() { int m = 12; float m = 12; printf("%d", m) } |
| A. | 12 |
| B. | Compilation Error |
| C. | 12.000000 |
| D. | Runtime Error |
| E. | None of these |
| Answer» C. 12.000000 | |
| 11. |
Will the following C code compile without any error?#include <stdio.h> int main() { for (int n = 0; n < 5; n++); return 0; } |
| A. | No |
| B. | Yes |
| C. | Garbage value |
| D. | Depends on the C standard implemented by compilers |
| E. | None of these |
| Answer» E. None of these | |
| 12. |
Which of the following format identifier can never be used for the variable var?#include <stdio.h> int main() { char *variable = "Advanced Training in C by interviewmania.com"; } |
| A. | %s |
| B. | %c |
| C. | %d |
| D. | %f |
| E. | None of these |
| Answer» E. None of these | |
| 13. |
What will be the output of the following C code?#include <stdio.h> int num; void main() { printf("%d", num); } |
| A. | Compilation Error |
| B. | 0 |
| C. | Runtime Error |
| D. | Garbage value |
| E. | None of these |
| Answer» C. Runtime Error | |
| 14. |
What will be the output of the following C code? #include <stdio.h> void main() { A(); printf("%d", n); } int n; void A() { n = 10; } |
| A. | 10 |
| B. | 0 |
| C. | Compilation Error |
| D. | Depend on compiler |
| E. | None of these |
| Answer» D. Depend on compiler | |
| 15. |
Which part of the program address space is p stored in the following C code?#include <stdio.h> int *ptr; int main() { int n = 0; ptr = &n; return 0; } |
| A. | Data segment |
| B. | Code/text segment |
| C. | Stack |
| D. | Bss segment |
| Answer» E. | |
| 16. |
What will be the output of the following C code? #include <stdio.h> void main() { static int n; if (n++ < 5) main(); } |
| A. | 5 |
| B. | Infinite calls to main |
| C. | Runtime Error |
| D. | Varies |
| E. | main is called twice |
| Answer» F. | |
| 17. |
What is the problem in following variable declaration?float 2B-H-K?; |
| A. | The special character - |
| B. | The special character ? |
| C. | The variable name begins with an integer |
| D. | All of above |
| E. | None of these |
| Answer» E. None of these | |
| 18. |
What will happen if the following C code is executed?#include <stdio.h> int main() { int var = 15; printf("%d", var); return 0; } |
| A. | 10 |
| B. | 12 |
| C. | 15 |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 19. |
What is the output of this C code?#include <stdio.h>int main(){ printf("My Name is - %d n", myName); return 0;} |
| A. | My Name is - myName; |
| B. | My Name is - followed by a junk value |
| C. | Compile time error |
| D. | My Name is - |
| Answer» D. My Name is - | |
| 20. |
Which of the following is an external variable in the following C code? #include <stdio.h> int function(int p) { int q; return q; } int main() { int r; function(r); } int s; |
| A. | p |
| B. | q |
| C. | r |
| D. | s |
| E. | None of these |
| Answer» E. None of these | |
| 21. |
What will be the output of the following C code?#include <stdio.h> int n = 15; void main() { int n = 5; printf("%d ", n); { int n = 10; } printf("%d", n); } |
| A. | 15 5 |
| B. | 5 15 |
| C. | 10 5 |
| D. | 5 10 |
| E. | 5 5 |
| Answer» F. | |
| 22. |
What will be the output of the following C code?#include <stdio.h> int num = 10; void main() { int num = 5; printf("%d ", num); { num = 6; } printf("%d", num); } |
| A. | 10 5 |
| B. | 5 10 |
| C. | 6 5 |
| D. | 5 6 |
| E. | None of these |
| Answer» E. None of these | |
| 23. |
Which part of the program address space is ptr stored in the following C code?#include <stdio.h> int *ptr = NULL; int main() { int n = 0; ptr = &n; return 0; } |
| A. | 0 |
| B. | Code/text segment |
| C. | Data segment |
| D. | Bss segment |
| E. | Stack |
| Answer» D. Bss segment | |
| 24. |
What will be the output of the following C code (after linking to source file having definition of arrayA)?#include <stdio.h> int main() { extern arrayA[]; printf("%d n", arrayA[0]); } |
| A. | Compile time error due to multiple definitio |
| B. | Compile time error because size of array is not provided |
| C. | Compile time error because datatype of array is not provided |
| D. | Value of arrayA[0]; |
| E. | None of these |
| Answer» D. Value of arrayA[0]; | |
| 25. |
What will be the output of the following C code (without linking the source file in which arrayA is defined)?#include <stdio.h> int main() { extern arrayA[]; printf("Interview Mania n"); } |
| A. | Linking error due to undefined reference |
| B. | Compile time error because datatype of array is not provided |
| C. | Compile time error because size of array is not provided |
| D. | Interview Mania |
| E. | None of these |
| Answer» E. None of these | |
| 26. |
What will be the output of the following C code?#include <stdio.h> int n; int main() { extern int n; if (p == 0) printf("Scope rules follow here n"); } |
| A. | Scope rules followed |
| B. | Nothing will be printed as value of n is not zero because i is an automatic variable |
| C. | Compile time error due to multiple declaration |
| D. | Compile time error due to not defining type in statement extern n |
| E. | None of these |
| Answer» B. Nothing will be printed as value of n is not zero because i is an automatic variable | |
| 27. |
What will be the output of the following C code? #include <stdio.h> void function(); int main() { static int q = 25; function(); } void function() { static int q; printf("%d", q); } |
| A. | 25 |
| B. | Compilation Error |
| C. | Runtime Error |
| D. | 0 |
| E. | None of these |
| Answer» E. None of these | |
| 28. |
What will be the sequence of allocation and deletion of variables in the following C code?#include <stdio.h> int main() { int num; { int var; } } |
| A. | var->num, num->var |
| B. | var->num, var->num |
| C. | num->var, var->num |
| D. | num->var, num->var |
| E. | None of these |
| Answer» D. num->var, num->var | |
| 29. |
What will happen if the below program is executed?#include <stdio.h>int main(){ int main = 25; printf("%d", main); return 0;} |
| A. | It will cause a compile-time error |
| B. | It will cause a run-time error |
| C. | It will run without any error and prints |
| D. | It will experience infinite looping |
| Answer» D. It will experience infinite looping | |
| 30. |
What will be the output of the following C code?#include <stdio.h> int main() { register const int p = 16; p = 17; printf("%d n", p); } |
| A. | Compilation Error |
| B. | 17 |
| C. | 16 |
| D. | Garbage value |
| E. | None of these |
| Answer» B. 17 | |
| 31. |
Comment on the following 2 C Example programs.#include <stdio.h> //Example 1 int main() { int p; int q; int r; } #include <stdio.h> //Example 2 int main() { int p; { int q; } { int r; } } |
| A. | Scope of r is till the end of the main function in Example 2 |
| B. | In Example 1, variables p, q and r can be used anywhere in main function whereas in Example 2, variables q and r can be used only inside their respective blocks. |
| C. | Both are same |
| D. | Scope of p, q and r is till the end of the main function in Example 2. |
| E. | None of these |
| Answer» C. Both are same | |
| 32. |
Which variable has the longest scope in the following C code?#include <stdio.h> int p; int main() { int q; return 0; } int r; |
| A. | p |
| B. | q |
| C. | r |
| D. | both p and r |
| E. | None of these |
| Answer» B. q | |
| 33. |
Comment on the output of the following C code.#include <stdio.h> int main() { int k; for (k = 0; k < 10; k++) int m = k; printf("%d", m); } |
| A. | Redeclaration of m in same scope throws error |
| B. | Syntax error in declaration of m |
| C. | m is out of scope when printf is called |
| D. | No errors, program will show the output 15 |
| E. | None of these |
| Answer» C. m is out of scope when printf is called | |
| 34. |
What will be the output of the following C code?#include <stdio.h> static int var = 51; void main() { int var = 91; { var = 41; } printf("%d", var); } |
| A. | 51 |
| B. | 91 |
| C. | 41 |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 35. |
What will be the output of the following C code?#include <stdio.h> void main() { { int R = 81; } printf("%d", R); } |
| A. | Undefined |
| B. | Compilation Error |
| C. | 81 |
| D. | Garbage value |
| E. | None of these |
| Answer» C. 81 | |
| 36. |
What will be the output of the following C code?#include <stdio.h> int num; void main() { A(); printf("%d", num); } void A() { num = 14; } |
| A. | 14 |
| B. | 0 |
| C. | Undefined |
| D. | Compilation Error |
| E. | None of these |
| Answer» B. 0 | |
| 37. |
What will be the output of the following C code? #include <stdio.h> int num = 15; void main() { int num = 13; A(); printf("%d", num); } void A() { num = 18; B(); } void B() { printf("%d ", num); } |
| A. | 15 13 |
| B. | 13 15 |
| C. | 13 18 |
| D. | 18 13 |
| E. | None of these |
| Answer» E. None of these | |
| 38. |
What will be the output of the following C code?#include <stdio.h> void main() { int num = 13; { num = 14; printf("%d", num); } } |
| A. | 14 |
| B. | 13 |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» B. 13 | |
| 39. |
What will be the output of the following C code?#include <stdio.h> void main() { static double s; int s; printf("s is %d", s); } |
| A. | s is 0 |
| B. | Compilation Error |
| C. | Runtime Error |
| D. | Garbage value |
| E. | None of these |
| Answer» C. Runtime Error | |
| 40. |
What will be the output of the following C code?#include <stdio.h> static int num; void main() { int num; printf("num is %d", num); } |
| A. | Runtime Error |
| B. | num is 0 |
| C. | Compilation Error |
| D. | Garbage value |
| E. | None of these |
| Answer» C. Compilation Error | |
| 41. |
What will be the output of the following C code?#include <stdio.h> void main() { static int R; printf("R is %d", R); } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | Garbage value |
| D. | R is 0 |
| E. | None of these |
| Answer» E. None of these | |
| 42. |
What will be the output of the following C code?#include <stdio.h> void main() { fun(); fun(); } void fun() { static int R = 10; R++; printf("%d ", R); } |
| A. | 10 11 |
| B. | 11 10 |
| C. | 12 11 |
| D. | 11 12 |
| E. | None of these |
| Answer» E. None of these | |
| 43. |
What will be the output of the following C code if these two files namely sample.c and sample1.c are linked and run? -------file sample.c------- #include <stdio.h> #include ""sample.h"" int main() { n = 12; printf(""%d "", n); function(); } -----file sample1.c------ #include <stdio.h> #include ""sample.h"" int function() { printf(""%d n"", n); } -----file sample.h----- #include <stdio.h> #include <stdlib.h> static int n; |
| A. | 0 0 |
| B. | 0 12 |
| C. | 12 0 |
| D. | 12 12 |
| E. | None of these |
| Answer» D. 12 12 | |
| 44. |
What will be the output of the following C code?#include <stdio.h> int main() { register auto int num = 12; num = 13; printf("%d n", num); } |
| A. | 12 13 |
| B. | 13 12 |
| C. | 12 |
| D. | 13 |
| E. | Compilation Error |
| Answer» F. | |
| 45. |
What will be the output of the following C code?#include <stdio.h> int main() { register static int n = 13; n = 14; printf("%d n", n); } |
| A. | Compilation Error |
| B. | 13 |
| C. | 14 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 46. |
What will be the output of the following C code? #include <stdio.h> void main() { register int s; printf("%d", s); } |
| A. | Garbage value |
| B. | Compilation Error |
| C. | Nothing |
| D. | 0 |
| E. | None of these |
| Answer» E. None of these | |
| 47. |
What will be the output of the following C code?#include <stdio.h> void main() { register int num = 10; if (num < 12) { num++; main(); } } |
| A. | main is called once |
| B. | Segmentation fault |
| C. | main is called thrice |
| D. | main is called twice |
| E. | None of these |
| Answer» C. main is called thrice | |
| 48. |
What will be the output of the following C code?#include <stdio.h> register int p; void main() { printf("%d", p); } |
| A. | 0 |
| B. | Garbage value |
| C. | Compilation error |
| D. | Varies |
| E. | None of these |
| Answer» D. Varies | |
| 49. |
What will be the output of the following C code?#include <stdio.h> int main() { auto R = 110; const auto int *ptr = &R; printf("%d n", R); } |
| A. | Compilation Error |
| B. | Garbage value |
| C. | Depends on the compiler |
| D. | Depends on the standard |
| E. | 110 |
| Answer» F. | |
| 50. |
What will be the output of the following C code?#include <stdio.h> void function(auto int n); int main() { function(12); } void function(auto int n) { printf("%d n", n); } |
| A. | Compilation Error |
| B. | Depend on compiler |
| C. | Depends on the standard |
| D. | 12 |
| E. | None of these |
| Answer» B. Depend on compiler | |