MCQOPTIONS
Saved Bookmarks
This section includes 104 Mcqs, each offering curated multiple-choice questions to sharpen your C Preprocessor knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
Macros with arguments are not allowed. |
| A. | TRUE |
| B. | May Be |
| C. | FALSE |
| D. | Can't Say |
| Answer» C. FALSE | |
| 52. |
After preprocessing when the program is sent for compilation the macros are removed from the expanded source code. |
| A. | TRUE |
| B. | FALSE |
| C. | Can be true or false |
| D. | Can't Say |
| Answer» B. FALSE | |
| 53. |
Which of the following are correctly formed #define statements? |
| A. | #define INCH PER FEET 12 |
| B. | #define SQR(X) (X *X); |
| C. | #define SQR(X) X*X |
| D. | #define SQR(X) (X*X) |
| Answer» E. | |
| 54. |
What is a preprocessor directive |
| A. | a message from compiler to the programmer |
| B. | a message from programmer to the microprocessor |
| C. | a message from programmer to the preprocessor |
| D. | a message from compiler to the linker |
| Answer» D. a message from compiler to the linker | |
| 55. |
What will be the output of the program? #include #define MAX(a, b, c) (a>b ? a>c ? a : c: b>c ? b : c) int main() { int x; x = MAX(3+2, 2+7, 3+7); printf("%d n", x); return 0; } |
| A. | 3 |
| B. | 5 |
| C. | 10 |
| D. | 3+7 |
| Answer» D. 3+7 | |
| 56. |
What will be the output of the following C code? #include #define max 100 void main() { #if(max) printf("san"); #endif printf("foundry"); } |
| A. | error |
| B. | san |
| C. | foundry |
| D. | sanfoundry |
| Answer» E. | |
| 57. |
What will be the output of the following C code? #include #define a 2 main() { int r; #define a 5 r=a*2; printf("%d",r); } |
| A. | 10 |
| B. | 4 |
| C. | 2 |
| D. | 5 |
| Answer» B. 4 | |
| 58. |
The preprocessor directive which is used to remove the definition of an identifier which was previously defined with #define? |
| A. | #ifdef |
| B. | #undef |
| C. | #ifndef |
| D. | #def |
| Answer» C. #ifndef | |
| 59. |
What will be the output of the following C code? #include #define hello 10 void main() { printf("%d",hello); #undef hello printf("%d",hello); } |
| A. | 10 |
| B. | hello |
| C. | error |
| D. | 1010 |
| Answer» D. 1010 | |
| 60. |
The preprocessor directive which checks whether a constant expression results in a zero or non-zero value __________ |
| A. | #if |
| B. | #ifdef |
| C. | #undef |
| D. | #ifndef |
| Answer» B. #ifdef | |
| 61. |
What will be the output of the following C code? #include #define san 557 main() { #ifndef san printf("yes"); #endif printf("no"); } |
| A. | error |
| B. | yes |
| C. | no |
| D. | yesno |
| Answer» D. yesno | |
| 62. |
What will be the output of the following C code? #include void main() { #ifndef max printf("hello"); #endif printf("hi"); } |
| A. | hello |
| B. | hellohi |
| C. | error |
| D. | hi |
| Answer» C. error | |
| 63. |
Which of the following is not a preprocessor directive? |
| A. | #error |
| B. | #pragma |
| C. | #if |
| D. | #ifelse |
| Answer» E. | |
| 64. |
_______________ is the preprocessor directive which is used to end the scope of #ifdef. |
| A. | #elif |
| B. | #ifndef |
| C. | #endif |
| D. | #if |
| Answer» D. #if | |
| 65. |
What will be the output of the following C code? #define sqr(x) x*x main() { int a1; a1=25/sqr(5); printf("%d",a1); } |
| A. | 25 |
| B. | 1 |
| C. | 5 |
| D. | error |
| Answer» B. 1 | |
| 66. |
What will be the output of the following C code? #include #define max 100 main() { #ifdef max printf("hello"); } |
| A. | 100 |
| B. | hello |
| C. | hello |
| D. | error |
| Answer» E. | |
| 67. |
What will be the output of the following C code? #include #define INDIA 1 #define US 2 #define CC US main() { #if CC==INDIA printf("Rupee"); #elif CC==US printf("Dollar"); #else printf("Euro"); #endif } |
| A. | Euro |
| B. | Rupee |
| C. | Dollar |
| D. | Error |
| Answer» D. Error | |
| 68. |
What will be the output of the following C code? #include void f() { #define sf 100 printf("%d",sf); } int main() { #define sf 99; f(); printf("%d",sf); } |
| A. | error |
| B. | 100 |
| C. | 99 |
| D. | 10099 |
| Answer» B. 100 | |
| 69. |
What will be the output of the following C code? #include #define sf 10 main() { if(sf==100) printf("good"); else { printf("bad"); sf=100; } printf("%d",sf); } |
| A. | 100 |
| B. | bad |
| C. | 10 |
| D. | error |
| Answer» E. | |
| 70. |
The purpose of the preprocessor directive #error is that ____________ |
| A. | It rectifies any error present in the code |
| B. | It rectifies only the first error which occurs in the code |
| C. | It causes the preprocessor to report a fatal error |
| D. | It causes the preprocessor to ignore an error |
| Answer» D. It causes the preprocessor to ignore an error | |
| 71. |
What will be the output of the following C code? #include #define hello main() { #ifdef hello #define hi 4 #else #define hi 5 #endif printf("%d",hi); } |
| A. | 4 |
| B. | 5 |
| C. | 45 |
| D. | error |
| Answer» B. 5 | |
| 72. |
What will be the output of the following C code? #include #define san 10 main() { #ifdef san #define san 20 #endif printf("%d",san); } |
| A. | 10 |
| B. | 20 |
| C. | Error |
| D. | 1020 |
| Answer» C. Error | |
| 73. |
What will be the output of the following C code? #include #define hello 10 main() { #ifdef hello #undef hello #define hello 100 #else #define hello 200 #endif printf("%d",hello); } |
| A. | Error |
| B. | 10 |
| C. | 100 |
| D. | 200 |
| Answer» D. 200 | |
| 74. |
What will be the output of the following C code? #include #define max 20 main() { #ifndef max #define min 10 #else #define min 30 #endif printf("%d",min); } |
| A. | 10 |
| B. | 20 |
| C. | 30 |
| D. | error |
| Answer» D. error | |
| 75. |
In which stage the following code #include gets replaced by the contents of the file stdio.h |
| A. | During editing |
| B. | During linking |
| C. | During execution |
| D. | During preprocessing |
| Answer» E. | |
| 76. |
What is #include directive? |
| A. | Tells the preprocessor to grab the text of a file and place it directly into the current file |
| B. | Statements are not typically placed at the top of a program |
| C. | All of the mentioned |
| D. | D. |
| Answer» B. Statements are not typically placed at the top of a program | |
| 77. |
The preprocessor provides the ability for _______________ |
| A. | The inclusion of header files |
| B. | The inclusion of macro expansions |
| C. | Conditional compilation and line control |
| D. | All of the mentioned |
| Answer» E. | |
| 78. |
If #include is used with file name in angular brackets. |
| A. | The file is searched for in the standard compiler include paths |
| B. | The search path is expanded to include the current source directory |
| C. | The search path will expand |
| D. | None of the mentioned |
| Answer» B. The search path is expanded to include the current source directory | |
| 79. |
The C-preprocessors are specified with _________symbol. |
| A. | # |
| B. | $ |
| C. | |
| D. | & |
| Answer» B. $ | |
| 80. |
What will be the output of the following C code? #include int main() { int one = 1, two = 2; #ifdef next one = 2; two = 1; #endif printf("%d, %d", one, two); } |
| A. | 1, 1 |
| B. | 1, 2 |
| C. | 2, 1 |
| D. | 2, 2 |
| Answer» C. 2, 1 | |
| 81. |
#include statement must be written __________ |
| A. | Before main() |
| B. | Before any scanf/printf |
| C. | After main() |
| D. | It can be written anywhere |
| Answer» C. After main() | |
| 82. |
#pragma exit is primarily used for? |
| A. | Checking memory leaks after exiting the program |
| B. | Informing Operating System that program has terminated |
| C. | Running a function at exiting the program |
| D. | No such preprocessor exist |
| Answer» D. No such preprocessor exist | |
| 83. |
Which of the following are C preprocessors? |
| A. | #ifdef |
| B. | #define |
| C. | #endif |
| D. | all of the mentioned |
| Answer» E. | |
| 84. |
What will be the output of the program? #include #define MAX(a, b) (a > b ? a : b) int main() { int x; x = MAX(3+2, 2+7); printf("%d n", x); return 0; } |
| A. | 8 |
| B. | 9 |
| C. | 6 |
| D. | 4 |
| Answer» C. 6 | |
| 85. |
What will be the output of the program? #include #define FUN(i, j) i##j int main() { int va1=10; int va12=20; printf("%d n", FUN(va1, 2)); return 0; } |
| A. | 10 |
| B. | 20 |
| C. | 1020 |
| D. | 12 |
| Answer» C. 1020 | |
| 86. |
What will be the output of the program? #include #define MIN(x, y) (x 0) printf("%d n", z); return 0; } |
| A. | 3 |
| B. | 4 |
| C. | No output |
| Answer» B. 4 | |
| 87. |
What will be the output of the program? #include #define SWAP(a, b) int t; t=a, a=b, b=t; int main() { int a=10, b=12; SWAP(a, b); printf("a = %d, b = %d n", a, b); return 0; } |
| A. | a = 10, b = 12 |
| B. | a = 12, b = 10 |
| C. | Error: Declaration not allowed in macro |
| D. | Error: Undefined symbol 't' |
| Answer» C. Error: Declaration not allowed in macro | |
| 88. |
What will be the output of the program? #include #define PRINT(int) printf("int=%d, ", int); int main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); return 0; } |
| A. | int=2, int=3, int=4 |
| B. | int=2, int=2, int=2 |
| C. | int=3, int=3, int=3 |
| D. | int=4, int=4, int=4 |
| Answer» B. int=2, int=2, int=2 | |
| 89. |
What will be the output of the program? #include #define CUBE(x) (x*x*x) int main() { int a, b=3; a = CUBE(b++); printf("%d, %d n", a, b); return 0; } |
| A. | 9, 4 |
| B. | 27, 4 |
| C. | 27, 6 |
| D. | Error |
| Answer» D. Error | |
| 90. |
What will be the output of the program? #include #define JOIN(s1, s2) printf("%s=%s %s=%s n", #s1, s1, #s2, s2); int main() { char *str1="India"; char *str2="BIX"; JOIN(str1, str2); return 0; } |
| A. | str1=IndiaBIX str2=BIX |
| B. | str1=India str2=BIX |
| C. | str1=India str2=IndiaBIX |
| D. | Error: in macro substitution |
| Answer» C. str1=India str2=IndiaBIX | |
| 91. |
What will be the output of the program? #include #define SQUARE(x) x*x int main() { float s=10, u=30, t=2, a; a = 2*(s-u*t)/SQUARE(t); printf("Result = %f", a); return 0; } |
| A. | Result = -100.000000 |
| B. | Result = -25.000000 |
| C. | Result = 0.000000 |
| D. | Result = 100.000000 |
| Answer» B. Result = -25.000000 | |
| 92. |
What will be the output of the program? #include #define MAN(x, y) ((x)>(y)) ? (x):(y); int main() { int i=10, j=5, k=0; k = MAN(++i, j++); printf("%d, %d, %d n", i, j, k); return 0; } |
| A. | 12, 6, 12 |
| B. | 11, 5, 11 |
| C. | 11, 5, Garbage |
| D. | 12, 6, Garbage |
| Answer» B. 11, 5, 11 | |
| 93. |
What will be the output of the program? #include #define SQR(x)(x*x) int main() { int a, b=3; a = SQR(b+2); printf("%d n", a); return 0; } |
| A. | 25 |
| B. | 11 |
| C. | Error |
| D. | Garbage value |
| Answer» C. Error | |
| 94. |
What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile? #include #define SWAP(a, b, c)(c t; t=a, a=b, b=t) int main() { int x=10, y=20; SWAP(x, y, int); printf("%d %d n", x, y); return 0; } |
| A. | It compiles |
| B. | Compiles with an warning |
| C. | Not compile |
| D. | Compiles and print nothing |
| Answer» D. Compiles and print nothing | |
| 95. |
What will be the output of the program? #include #define PRINT(i) printf("%d,",i) int main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); return 0; } |
| A. | 2, 3, 4, |
| B. | 2, 2, 2, |
| C. | 3, 3, 3, |
| D. | 4, 4, 4, |
| Answer» B. 2, 2, 2, | |
| 96. |
What will be the output of the program? #include #define MESS junk int main() { printf("MESS n"); return 0; } |
| A. | junk |
| B. | MESS |
| C. | Error |
| D. | Nothing will print |
| Answer» C. Error | |
| 97. |
What will be the output of the program? #include #define str(x) #x #define Xstr(x) str(x) #define oper multiply int main() { char *opername = Xstr(oper); printf("%s n", opername); return 0; } |
| A. | Error: in macro substitution |
| B. | Error: invalid reference 'x' in macro |
| C. | print 'multiply' |
| D. | No output |
| Answer» D. No output | |
| 98. |
Preprocessor directive #ifdef .. #else ... #endif is used for conditional compilation. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 99. |
There exists a way to prevent the same file from getting #included twice in the same program. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 100. |
Would the following typedef work? typedef #include l; |
| A. | Yes |
| B. | No |
| Answer» C. | |