Practice high-yield Programming & Software Development MCQs on C Preprocessor — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the program? #include<stdio.h> #define int char void main() { int i = 65; printf("sizeof(i)=%d", sizeof(i)); }
Correct Answer: Option B — sizeof(i)=1
Detailed Academic Explanation:
Since the #define replaces the string int by the macro char . So, here i is a variable of type char and not int .
💡Key Conceptual Anchor:C Preprocessor
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following program? #include<stdio.h> #define square(x) x*x void main() { int i; i = 64/square(4); printf("%d", i); }
Correct Answer: Option B — 64
Detailed Academic Explanation:
The macro call square(4) will be substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority and associativity left to right, so the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64.
💡Key Conceptual Anchor:C Preprocessor
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the program code? #include<stdio.h> #define a 10 void main() { #define a 50 printf("%d", a); }
Correct Answer: Option A — 50
Detailed Academic Explanation:
The preprocessor directives can be redefined anywhere in the program. So the most recently assigned value will be taken.
Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this : void main () { 100; printf ( " %d \n ", 100 ) ; } Note: 100; is an executable statement but with no action. So it doesn't give any problem.
💡Key Conceptual Anchor:C Preprocessor
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following program? #include<stdio.h> #define prod(a,b) a*b void main() { int x=3,y=4; printf("%d", prod(x+2,y-1)); }
Correct Answer: Option C — 10
Detailed Academic Explanation:
The macro expands and evaluates to as: x+2*y-1 => x+(2*y)-1 => 10
💡Key Conceptual Anchor:C Preprocessor
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be output if you will compile and execute the following c code? #include<stdio.h> #define max 5 void main(){ int i = 0; i = max++; printf("%d", i++); }
Correct Answer: Option E — Compiler Error
Detailed Academic Explanation:
main.c: In function ‘main’: main.c:5:12: error: lvalue required as increment operand i = max++;
💡Key Conceptual Anchor:C Preprocessor
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The output of the following program is: #define f(g,g2) g##g2 void main() { int var12=100; printf("%d", f(var,12)); }
Correct Answer: Option D — 100
Detailed Academic Explanation:
## is token pasting operator which simply combines all the parameters of macro into one variable. So, in f(var, 12), var and 12 combines to form var12 and replaces the f(var, 12) and hence the output is 100.
💡Key Conceptual Anchor:C Preprocessor
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Find the output of the following program. #define INC(X) X++ void main() { int x=4; printf("%d", INC(x++)); }
Correct Answer: Option D — Error
Detailed Academic Explanation:
L value is required for this expression (x++) which is illegal.
💡Key Conceptual Anchor:C Preprocessor
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the C preprocessor in C programming?
Correct Answer: Option C — Preprocess code before compilation
Detailed Academic Explanation:
Preprocess code before compilation is the correct answer to “What is the purpose of the C preprocessor in C programming”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which directive is used to include the contents of another file in a C program using the C preprocessor?
Correct Answer: Option B — #include
Detailed Academic Explanation:
#include is the correct answer to “Which directive is used to include the contents of another file in a C program using the C preprocessor”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #define directive in C preprocessing?
Correct Answer: Option B — To define a macro
Detailed Academic Explanation:
To define a macro is the correct answer to “What is the purpose of the #define directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, which directive is used to conditionally include code based on preprocessor macros?
Correct Answer: Option C — #if
Detailed Academic Explanation:
#if is the correct answer to “In C, which directive is used to conditionally include code based on preprocessor macros”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the #ifdef DEBUG directive if the DEBUG macro is defined?
Correct Answer: Option A — The code block following it is included
Detailed Academic Explanation:
The code block following it is included is the correct answer to “What is the result of the #ifdef DEBUG directive if the DEBUG macro is defined”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which directive in C preprocessing is used to define a macro with parameters?
Correct Answer: Option A — #define
Detailed Academic Explanation:
#define is the correct answer to “Which directive in C preprocessing is used to define a macro with parameters”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C preprocessing, what is the purpose of the #undef directive?
Correct Answer: Option A — To undefine a macro
Detailed Academic Explanation:
To undefine a macro is the correct answer to “In C preprocessing, what is the purpose of the #undef directive”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the #ifndef directive do in C preprocessing?
Correct Answer: Option B — Checks if a macro is not defined
Detailed Academic Explanation:
Checks if a macro is not defined is the correct answer to “What does the #ifndef directive do in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what does the #pragma directive do in C preprocessing?
Correct Answer: Option B — Provides compiler-specific instructions
Detailed Academic Explanation:
Provides compiler-specific instructions is the correct answer to “In C, what does the #pragma directive do in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #include directive in C preprocessing?
Correct Answer: Option B — To include a header file
Detailed Academic Explanation:
To include a header file is the correct answer to “What is the purpose of the #include directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #if directive in C preprocessing?
Correct Answer: Option B — To conditionally include code
Detailed Academic Explanation:
To conditionally include code is the correct answer to “What is the purpose of the #if directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, how do you use the #ifdef directive to conditionally include code if a macro is defined?
Correct Answer: Option A — #ifdef MACRO
Detailed Academic Explanation:
#ifdef MACRO is the correct answer to “In C, how do you use the #ifdef directive to conditionally include code if a macro is defined”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #error directive in C preprocessing?
Correct Answer: Option A — To include an error message in the code
Detailed Academic Explanation:
To include an error message in the code is the correct answer to “What is the purpose of the #error directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the #ifndef DEBUG directive if the DEBUG macro is defined?
Correct Answer: Option B — The code block following it is excluded
Detailed Academic Explanation:
The code block following it is excluded is the correct answer to “What is the result of the #ifndef DEBUG directive if the DEBUG macro is defined”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which directive in C preprocessing is used to concatenate two or more strings?
Correct Answer: Option D — #define
Detailed Academic Explanation:
#define is the correct answer to “Which directive in C preprocessing is used to concatenate two or more strings”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what does the #line directive do in C preprocessing?
Correct Answer: Option A — Specifies the line number in the source file
Detailed Academic Explanation:
Specifies the line number in the source file is the correct answer to “In C, what does the #line directive do in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #pragma once directive in C preprocessing?
Correct Answer: Option A — Prevents recursive inclusion of header files
Detailed Academic Explanation:
Prevents recursive inclusion of header files is the correct answer to “What is the purpose of the #pragma once directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C preprocessing, what is the purpose of the #elif directive?
Correct Answer: Option C — Provides an alternative condition
Detailed Academic Explanation:
Provides an alternative condition is the correct answer to “In C preprocessing, what is the purpose of the #elif directive”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the #error directive in C preprocessing?
Correct Answer: Option A — Generates a compilation error with a specified error message
Detailed Academic Explanation:
Generates a compilation error with a specified error message is the correct answer to “What is the result of the #error directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #pragma message directive in C preprocessing?
Correct Answer: Option A — Includes a message in the code
Detailed Academic Explanation:
Includes a message in the code is the correct answer to “What is the purpose of the #pragma message directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, how do you use the #ifndef directive to conditionally include code if a macro is not defined?
Correct Answer: Option A — #ifndef MACRO
Detailed Academic Explanation:
#ifndef MACRO is the correct answer to “In C, how do you use the #ifndef directive to conditionally include code if a macro is not defined”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the #pragma once directive do in C preprocessing?
Correct Answer: Option A — Prevents multiple inclusion of header files
Detailed Academic Explanation:
Prevents multiple inclusion of header files is the correct answer to “What does the #pragma once directive do in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the #ifdef directive?
Correct Answer: Option A — Checks if a macro is defined
Detailed Academic Explanation:
Checks if a macro is defined is the correct answer to “In C, what is the purpose of the #ifdef directive”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #pragma warning directive in C preprocessing?
Correct Answer: Option A — Generates a warning message
Detailed Academic Explanation:
Generates a warning message is the correct answer to “What is the purpose of the #pragma warning directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C preprocessing, what is the purpose of the #elifdef directive?
Correct Answer: Option C — Provides an alternative condition
Detailed Academic Explanation:
Provides an alternative condition is the correct answer to “In C preprocessing, what is the purpose of the #elifdef directive”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the #pragma message directive in C preprocessing?
Correct Answer: Option A — Includes a message in the code
Detailed Academic Explanation:
Includes a message in the code is the correct answer to “What is the result of the #pragma message directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the #undef directive in C preprocessing?
Correct Answer: Option A — Undefines a macro
Detailed Academic Explanation:
Undefines a macro is the correct answer to “What is the purpose of the #undef directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C preprocessing, what is the purpose of the #elifndef directive?
Correct Answer: Option B — Checks if a macro is not defined
Detailed Academic Explanation:
Checks if a macro is not defined is the correct answer to “In C preprocessing, what is the purpose of the #elifndef directive”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the #pragma warning directive in C preprocessing?
Correct Answer: Option A — Generates a warning message
Detailed Academic Explanation:
Generates a warning message is the correct answer to “What is the result of the #pragma warning directive in C preprocessing”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the #line directive?
Correct Answer: Option A — Specifies the line number and filename in the source file
Detailed Academic Explanation:
Specifies the line number and filename in the source file is the correct answer to “In C, what is the purpose of the #line directive”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
C preprocessor
Correct Answer: Option E — All of the above
Detailed Academic Explanation:
All of the above is the correct answer to “C preprocessor”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A preprocessor command
Correct Answer: Option C — has # as the first character
Detailed Academic Explanation:
has # as the first character is the correct answer to “A preprocessor command”. This question is standard in competitive examination syllabi for C Preprocessor.
💡Key Conceptual Anchor:C Preprocessor
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.