

MCQOPTIONS
Saved Bookmarks
This section includes 46 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. |
Which of the following is the correct output for the program given below? #include <stdio.h>#define SQR(k) (k * k)int main( ){ int p, q = 5 ; p = SQR (q + 3) ; printf ("%d n" , p) ; return 0 ;} |
A. | 64 |
B. | 23 |
C. | Error |
D. | Garbage value |
Answer» C. Error | |
2. |
What will be the output of the following C code? #include <stdio.h> #define Winter int main() { #ifdef Winter printf("Winter t"); #undef Winter #endif #ifdef Winter printf("Summer t"); #endif } |
A. | Garbage value |
B. | Summer |
C. | Winter |
D. | Compilation Error |
E. | None of these |
Answer» D. Compilation Error | |
3. |
What will be the output of the following C code?#include <stdio.h> #define MINIMUM 20 #if MINIMUM #define MAXIMUM 100 #endif int main() { printf("%d %d n", MAXIMUM, MINIMUM); return 0; } |
A. | MAXIMUM |
B. | MINIMUM |
C. | 20 |
D. | 100 |
E. | 100 20 |
Answer» F. | |
4. |
What will be the output of the following C code?#include <stdio.h> #define MINIMUM 21); #ifdef MINIMUM #define MAXIMUM 210 #endif int main() { printf("%d %d n", MAXIMUM, MINIMUM return 0; } |
A. | 21 210 |
B. | 210 21 |
C. | Compilation Error |
D. | Garbage value |
E. | None of these |
Answer» C. Compilation Error | |
5. |
What will be the output of the following C code?#include <stdio.h> #define MINIMUM 30 #ifdef(MINIMUM) #define MAXIMUM 250 #endif int main() { printf("%d %d n", MAXIMUM, MINIMUM); return 0; } |
A. | Preprocessor error |
B. | Garbage value |
C. | Compilation Error |
D. | 250 30 |
E. | None of these |
Answer» D. 250 30 | |
6. |
What will be the output of the following C code? #include <stdio.h> #define MINIMUM 15 #if defined(MINIMUM) - (!defined(MAXIMUM)) #define MAXIMUM 115 #endif int main() { printf("%d %d n", MAXIMUM, MINIMUM); return 0; } |
A. | 15 115 |
B. | 115 15 |
C. | Garbage value |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
7. |
What will be the output of the following C code?#include <stdio.h> #define MINIMUM 25 #if defined(MINIMUM) + defined(MAXIMUM) #define MAXIMUM 125 #endif int main() { printf("%d %d n", MAXIMUM, MINIMUM); return 0; } |
A. | Garbage value |
B. | Compilation Error |
C. | 25 125 |
D. | 125 25 |
E. | None of these |
Answer» E. None of these | |
8. |
What will be the output of the following C code? #include <stdio.h> #define MINIMUM 10 #ifdef MINIMUM #define MAXIMUM 110 #endif int main() { printf("%d %d n", MAXIMUM, MINIMUM); return 0; } |
A. | 10 |
B. | 110 |
C. | 10 110 |
D. | 110 10 |
E. | Compilation Error |
Answer» E. Compilation Error | |
9. |
What will be the output of the following C code?#include <stdio.h>#define fun(p, q) p * q = 101int main(){ printf("Interview Mania n");} |
A. | Compilation error as lvalue is required for the expression p*q=101 |
B. | Interview Mania |
C. | Preprocessor error as lvalue is required for the expression p*q=101 |
D. | Runtime error as lvalue is required for the expression p*q=101 |
E. | None of these |
Answer» C. Preprocessor error as lvalue is required for the expression p*q=101 | |
10. |
What will be the output of the following C code?#include <stdio.h> #define calc(p, q) p / q + p int main() { int a = -10, b = 5; printf("%d n", calc(a + b, 5)); return 0; } |
A. | -10 |
B. | -14 |
C. | 5 |
D. | Compilation Error |
E. | None of these |
Answer» C. 5 | |
11. |
What will be the output of the following C code?#include <stdio.h> #define fun(p, q) #p #q int main() { printf("%s n", fun(a, b)); return 0; } |
A. | Compilation Error |
B. | pq |
C. | ab |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
12. |
What will be the output of the following C code? #include <stdio.h> #define fun(p, q) " p ## q " int main() { printf("%s n", fun(a, b)); } |
A. | a ## b |
B. | p ## q |
C. | Compilation Error |
D. | Nothing |
E. | None of these |
Answer» C. Compilation Error | |
13. |
What will be the output of the following C code?#include <stdio.h> #define function(p, q) p ## q int main() { printf("%s n", function(a, b)); } |
A. | p q |
B. | a b |
C. | Undefined behaviour |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
14. |
What will be the output of the following C code?#include <stdio.h> #define Cprogram int main() { int p = 21; #ifdef Cprogram p = 11; printf("%d", Cprogram); } |
A. | 21 |
B. | Garbage value |
C. | 11 |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
15. |
What will be the output of the following C code?#include <stdio.h> int calc(int, int); #define calc(p, q) p / q + p int main() { int a = -17, b = 12; printf("%d ",calc(a + b, 12)); #undef calc printf("%d n",calc(a + b, 12)); } int calc(int p, int q) { return p / q + p; } |
A. | Compilation Error |
B. | -17 12 |
C. | -21 -5 |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
16. |
What will be the output of the following C code?#include <stdio.h> #include "printf" void main() { printf("Welcome"); } |
A. | Compilation Error |
B. | Depends on compiler |
C. | Welcome |
D. | Varies |
E. | None of these |
Answer» B. Depends on compiler | |
17. |
The below two lines are equivalent to ________.#define C_IO_HEADER <stdio.h> #include C_IO_HEADER |
A. | #include<stdio.h> |
B. | #include C_IO_HEADER |
C. | #include printf |
D. | #include<stdlib.h> |
E. | None of these |
Answer» B. #include C_IO_HEADER | |
18. |
What will be the output of the following C code snippet?#include (stdio.h) void main() { printf("Welcome"); } |
A. | Depends on compiler |
B. | Compilation Error |
C. | Welcome |
D. | Nothing |
E. | None of these |
Answer» C. Welcome | |
19. |
What will be the output of the following C code?#include <stdio.h> # define count void fun() { printf("Welcome"); } void main() { count; fun(); } |
A. | Garbage value |
B. | Welcome |
C. | Compilation Error |
D. | Nothing |
E. | None of these |
Answer» C. Compilation Error | |
20. |
What will be the output of the following C code? #include <stdio.h> void main() { #define count 55 count = 23; printf("%d", count); } |
A. | 23 |
B. | Garbage value |
C. | 55 |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
21. |
What will be the output of the following C code?#include <stdio.h> #define system 25 int main() { int n = 25; #if system == n printf("Interview "); #endif #if system == 25 printf("Mania n"); #endif } |
A. | Interview |
B. | Interview Mania |
C. | Mania |
D. | Compilation Error |
E. | None of these |
Answer» D. Compilation Error | |
22. |
What is the output of this C code?#include <stdio.h> #define calc(n, m) n / m + n int main() { int a = -16, b = 13; printf("%d ", calc(a + b, 13)); printf("%d n", calc(-13, 13)); return 0; } |
A. | Divided by zero exception |
B. | -14 divided by zero exception |
C. | -14 -18 |
D. | -18 -14 |
E. | None of these |
Answer» E. None of these | |
23. |
What will be the output of the following C code?#include <stdio.h> void fun(); int main() { #define max 15 fun(); return 0; } void fun() { printf("%d n", max * 15); } |
A. | 15 |
B. | Compilation Error |
C. | Garbage value |
D. | 225 |
E. | None of these |
Answer» E. None of these | |
24. |
What will be the output of the following C code?#include <stdio.h> void fun(); int main() { #define calc(p, q) p / q + p fun(); } void fun() { printf("%d n", calc(-10, 10)); } |
A. | -11 |
B. | -10 |
C. | Runtime Error |
D. | Compilation Error |
E. | None of these |
Answer» B. -10 | |
25. |
What will be the output of the following C code?#include <stdio.h> #define calcA 5 + 3 #define calcB 4 + 6 int main() { int Res = calcA * calcB; printf("%d n", Res); } |
A. | 5,3 |
B. | 4,6 |
C. | Compilation Error |
D. | 23 |
E. | None of these |
Answer» E. None of these | |
26. |
Comment on the output of the following C code. #include <stdio.h> #define num 200); int main() { printf("%d n", num } |
A. | Garbage value |
B. | Compile time error, there are no open braces in #define |
C. | 200 |
D. | Compile time error, the printf braces aren t closed |
E. | None of these |
Answer» D. Compile time error, the printf braces aren t closed | |
27. |
What will be the output of the following C code?#include <stdio.h> void main() { #define const int const min = 41; printf("%d", min); } |
A. | const |
B. | Compilation Error |
C. | 41 |
D. | Runtime Error |
E. | None of these |
Answer» D. Runtime Error | |
28. |
What will be the output of the following C code?#include <stdio.h> void main() { #define min 85 printf("%d", min); } |
A. | Depends on compiler |
B. | 85 |
C. | Compilation Error |
D. | Runtime Error |
E. | None of these |
Answer» C. Compilation Error | |
29. |
What will be the output of the following C code?#include <stdio.h> void main() { #define min 56; printf("%d", min); } |
A. | Depends on compiler |
B. | 56 |
C. | Runtime Error |
D. | Nothing |
E. | Compilation Error |
Answer» F. | |
30. |
What will be the output of the following C code?#include <stdio.h> #define function(p, q) p ## q void fun(); int main() { fun(); } void fun() { printf("%d n", function(10, 15)); } |
A. | 10 |
B. | 15 |
C. | 1510 |
D. | 1015 |
E. | None of these |
Answer» E. None of these | |
31. |
What will be the output of the following C code?#include <stdio.h> int main() { int forth = 4, fifth = 5; #ifdef next forth = 5; fifth = 4; #endif printf("%d, %d", forth, fifth); } |
A. | 4 |
B. | 5 |
C. | 4, 5 |
D. | 5, 4 |
E. | None of these |
Answer» D. 5, 4 | |
32. |
Comment on the output of the following C code.#include <stdio.h> #include "test.h" #include "test.h" int main() { //statements... } |
A. | False |
B. | True |
C. | Depends on compiler |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
33. |
The #else directive is used for _________. |
A. | Ending conditional text |
B. | Conditionally include source text if a macro name is defined |
C. | Conditionally include source text if the previous #if, #ifdef, #ifndef, or #elif test fails |
D. | Conditionally include source text if a macro name is not defined |
E. | None of these |
Answer» D. Conditionally include source text if a macro name is not defined | |
34. |
Conditional inclusion can be used for ___________. |
A. | Check for existence of a variable and doing something if it exists |
B. | Preventing multiple declarations of same function |
C. | Preventing multiple declarations of a variable |
D. | All of above |
E. | None of these |
Answer» E. None of these | |
35. |
Which of the following sequences are unaccepted in C language? |
A. | <pre class="prettyprint lang-c">#if<br> #undef<br> #endif<br></pre> |
B. | <pre class="prettyprint lang-c">#if<br> #else<br> #endif<br></pre> |
C. | <pre class="prettyprint lang-c">#if<br> #elif<br> #endif<br></pre> |
D. | <pre class="prettyprint lang-c"> #if<br> #if<br> #endif<br></pre> |
E. | None of these |
Answer» E. None of these | |
36. |
The else if in conditional inclusion is written by? |
A. | #elif |
B. | #elsif |
C. | #elseif |
D. | #else if |
E. | None of these |
Answer» B. #elsif | |
37. |
#include statement must be written __________. |
A. | It can be written anywhere |
B. | After main() |
C. | Before main() |
D. | Before any scanf/printf |
E. | None of these |
Answer» E. None of these | |
38. |
#include are _______ files and #include somefile.h ________ files. |
A. | Library, user-created header |
B. | User-created header, library |
C. | They can include all types of file |
D. | Library, Library |
E. | None of these |
Answer» D. Library, Library | |
39. |
The preprocessor provides the ability for _______________. |
A. | Conditional compilation and line control |
B. | The inclusion of macro expansions |
C. | The inclusion of header files |
D. | All of above |
E. | None of these |
Answer» E. None of these | |
40. |
If the file name is enclosed in double quotation marks, then _________. |
A. | The preprocessor treats it as a system-defined file |
B. | The preprocessor treats it as a user-defined file & system-defined file |
C. | The preprocessor treats it as a user-defined file |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
41. |
How is search done in #include and #include somelibrary.h normally or conventionally? |
A. | For both, search for somelibrary is done in implementation-defined manner |
B. | When former is used, search is done in implementation defined manner and latter is used to search current directory |
C. | When former is used, predefined directory is searched and when latter is used, current directory is searched and then predefined directories are searched |
D. | When former is used, current directory is searched and when latter is used, standard directory is searched |
E. | NA |
Answer» D. When former is used, current directory is searched and when latter is used, standard directory is searched | |
42. |
The below two lines are equivalent to ________. |
A. | #include<stdio.h> |
B. | #include C_IO_HEADER |
C. | #include printf |
D. | #include<stdlib.h> |
E. | None of these |
Answer» B. #include C_IO_HEADER | |
43. |
What will be the output of the following C code snippet? |
A. | Depends on compiler |
B. | Compilation Error |
C. | Welcome |
D. | Nothing |
E. | None of these |
Answer» C. Welcome | |
44. |
If the file name is enclosed in angle brackets, then ___________. |
A. | The preprocessor treats it as a user-defined file & system-defined file |
B. | The preprocessor treats it as a user-defined file |
C. | The preprocessor treats it as a system-defined file |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
45. |
How is search done in #include and #include somelibrary.h according to C standard? |
A. | For both, search for somelibrary is done in implementation-defined places |
B. | When former is used, search is done in implementation defined manner and when latter is used, current directory is searched |
C. | When former is used, standard directory is searched and when latter is used, current directory is searched |
D. | When former is used, current directory is searched and when latter is used, standard directory is searched |
E. | None of these |
Answer» C. When former is used, standard directory is searched and when latter is used, current directory is searched | |
46. |
What would happen if you create a file stdio.h and use #include stdio.h ? |
A. | The compiler won t accept the program |
B. | Both the files will be included |
C. | The predefined library file will be selected |
D. | The user-defined library file will be selected |
E. | None of these |
Answer» E. None of these | |