0% found this document useful (0 votes)
8 views

C Pre Processor

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

C Pre Processor

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1) What will be the output of following program ?

1 #include <stdio.h>
2 int main()
3 {
4 #ifdef debug
5 printf("Start debugging...");
6 #endif
7 printf("IncludeHelp");
8 return 0;
9 }

1. Start debugging...IncludeHelp
2. IncludeHelp
3. Error
4. debug

Answer

2) What will be the output of following program ?

1 #include <stdio.h>
2 #define MAX 100
3 int main()
4 {
5 #define MAX 20
6 printf("MAX=%d...",MAX);
7 return 0;
8 }

1. Error
2. MAx=100...
3. MAx=20...
4. MAX=10020

Answer

3) What will be the output of following program ?

1 #include <stdio.h>
2 #define FUN(x) x*x
3 int main()
4 {
5 int val=0;
6 val=128/FUN(8);
7 printf("val=%d",val);
8 return 0;
9 }

1. 2
/
2. 128
3. 64
4. 1

Answer

4) What will be the output of following program ?

1 #include <stdio.h>
2 #define FUN(x,y) x##y
3 int main()
4 {
5 int a1=10,a2=20;
6 printf("%d...%d",FUN(a,1),FUN(a,2));
7 return 0;
8 }

1. Error
2. 10...10
3. 20...20
4. 10...20

Answer

5) What will be the output of following program ?

1 #include <stdio.h>
2 #define LARGEST(x,y) (x>=y)?x:y
3 int main()
4 {
5 int a=10,b=20,l=0;
6 l=LARGEST(a++,b++);
7
8 printf("a=%d,b=%d,largest=%d",a,b,l);
9 return 0;
10 }

1. a=10,b=20,largest=20
2. a=11,b=21,largest=20
3. a=11,b=21,largest=21
4. a=11,b=22,largest=21

Answer

6) What will be the output of following program ? /


1 #include <stdio.h>
2
3 #define OFF 0
4 #if debug == OFF
5 int a=11;
6 #endif
7
8 int main()
9 {
10 int b=22;
11 printf("%d...%d",a,b);
12 return 0;
13 }

1. 11...22
2. Error
3. 11...11
4. 22...22

Answer

7) What will be the output of following program ?

1 #include <stdio.h>
2 #define TEXT IncludeHelp
3 int main()
4 {
5 printf("%s",TEXT);
6 return 0;
7 }

1. IncludeHelp
2. TEXT
3. Error
4. TEXT IncludeHelp

Answer

8) What will be the output of following program ?

1 #include <stdio.h>
2 #define VAR1 VAR2+10
3 #define VAR2 VAR1+20
4
5 int main()
6 {
7 printf("%d",VAR1);
8 return 0;
9 }
/
1. VAR2+10
2. VAR1+20
3. Error
4. 10

Answer

9) What will be the output of following program ?

1 #include <stdio.h>
2
3 #define SUM(x,y) int s; s=x+y; printf("sum=%d\n",s);
4 int main()
5 {
6 SUM(10,20);
7 return 0;
8 }

1. sum=30
2. 10,20
3. Error
4. sum=0

Answer

10) What will be the output of following program ?

1 #include <stdio.h>
2 #define MAX 99
3 int main()
4 {
5 printf("%d...",MAX);
6 #undef MAX
7 printf("%d",MAX);
8 return 0;
9 }

1. 99...0
2. 99...99
3. Error
4. MAX...MAX

Answer

You might also like