Skip to main content

C Preprocessor — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on C Preprocessor — Part 2 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
Question 1 of 40
★ FPSC ★ PPSC

Choose the correct statement. I. The scope of a macro definition need not be the entire program. II. The scope of a macro definition extends from the point of definition to the end of the file. III. New line is a macro definition delimiter. IV. A macro definition may go beyond a line.

Question 2 of 40
★ FPSC ★ PPSC

In which stage the following code #include<stdio.h> gets replaced by the contents of the file stdio.h

Question 3 of 40
★ FPSC ★ PPSC

What will be output after executing following code? #include<stdio.h> # define a 10 void main() { printf("%d..", a); foo(); printf("%d", a); } void foo() { #undef a #define a 50 }

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define max 20 main() { #ifndef max #define min 10 #else #define min 30 #endif printf("%d",min); }

Question 5 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #define display(text) "$" #text main() { printf(display(hello world)); }

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define Shyam(x) #x int main() { int marks=100; printf("value of %s is = %d\n",Shyam(marks),marks); return 0; }

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define max 100 void main() { #if(max%10) printf("Exam"); #endif printf("Veda"); }

Question 8 of 40
★ FPSC ★ PPSC

. . . . . . . . is the preprocessor directive which is used to end the scope of #ifdef.

Question 9 of 40
★ FPSC ★ PPSC

In the directive #pragma pack(n), if the value of 'n' is given to be 5, then what happens?

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define INDIA 1 #define US 2 #define CC US main() { #if CC==INDIA printf("Rupee"); #elif CC==US printf("Dollar"); #else printf("Euro"); #endif }

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following C code, if it is run on a 32 bit platform? #include<stdio.h> #pragma(1) struct test { int i; char j; }; main() { printf("%d",sizeof(struct test)); }

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define p( m ) printf( "t*" #m " = %s", t##m ) char tram[]="tram"; int main() { int x; x=p(ram); }

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define sf 10 main() { if(sf==100) printf("good"); else { printf("bad"); sf=100; } printf("%d",sf); }

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> void main() { #ifndef max printf("hello"); #endif printf("hi"); }

Question 15 of 40
★ FPSC ★ PPSC

The following C code results in an error. #include <stdio.h> #define world( n ) printf( "t^^" #n" = %c", t##n ) int t3=1; int main() { world(3); }

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #define F abc #define B def #define FB(arg) #arg #define FB1(arg) FB(arg) main() { printf(FB(F B)); FB1(F B); }

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define p( n,m ) printf( "%d", m##n ) int main() { p(3,4); }

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #define example(s,n) #s #n main() { printf(example(hello,world)); }

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define hello( n ) a##n int a3; int main() { int x; x=hello(3); if(x!=0) printf("hi"); else printf("good"); }

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define hello main() { #ifdef hello #define hi 4 #else #define hi 5 #endif printf("%d",hi); }

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #define display(text) printf(#text "@") main() { display(hello.); display(good morning!); }

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define p( n ) printf( "t%%\n" #n " = %d", t##n ) int t3=10; int main() { int x; x=p(3); }

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define p( n,m ) printf( "%d", m##n ) #define q(a,b) printf("%d",a##b) main() { p(3,4); q(5,6); }

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define hello 10 void main() { printf("%d",hello); #undef hello printf("%d",hello); }

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define display( n ) printf( "a" #n " = %d", a##n ) int main() { display(3); }

Question 26 of 40
★ FPSC ★ PPSC

The preprocessor directive used to give additional information to the compiler, beyond which is conveyed in the language . . . . . . . .

Question 27 of 40
★ FPSC ★ PPSC

Which of the following operators is used to concatenate two strings without space?

Question 28 of 40
★ FPSC ★ PPSC

#pragma GCC poison should be followed by a list of identifiers that are . . . . . . . .

Question 29 of 40
★ FPSC ★ PPSC

In the directive, #pragma pack(n), which of the following is not a valid value of n?

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #define a 2 main() { int r; #define a 5 r=a*2; printf("%d",r); }

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define max 100 main() { #ifdef max printf("hello"); }

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define hello 10 main() { #ifdef hello #undef hello #define hello 100 #else #define hello 200 #endif printf("%d",hello); }

Question 33 of 40
★ FPSC ★ PPSC

Which of the following is not a preprocessor directive?

Question 34 of 40
★ FPSC ★ PPSC

The preprocessor directive which is used to remove the definition of an identifier which was previously defined with #define?

Question 35 of 40
★ FPSC ★ PPSC

The function of __attribute__((packed)); can also be performed using . . . . . . . .

Question 36 of 40
★ FPSC ★ PPSC

The preprocessor directive which checks whether a constant expression results in a zero or non-zero value . . . . . . . .

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> void f() { #define sf 100 printf("%d",sf); } int main() { #define sf 99; f(); printf("%d",sf); }

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #define HELLO(a) #a main() { printf(HELLO(good morning)); }

Question 39 of 40
★ FPSC ★ PPSC

The purpose of the preprocessor directive #error is that . . . . . . . .

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include<stdio.h> #define ram 10 main() { #ifdef ram #define ram 20 #endif printf("%d",ram); }

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →