C Language MCQ’S | C Preprocessor 4

16.
What will be the output of the program?

#include<stdio.h>
#define JOIN(s1, s2) printf(“%s=%s %s=%s \n”, #s1, s1, #s2, s2);
int main()
{
char *str1=”Hello”;
char *str2=”Hi”;
JOIN(str1, str2);
return 0;
}

A. str1=HelloHi str2=Hi
B. str1=Hello str2=Hi
C. str1=Hello str2=HelloHi
D. Error: in macro substitution

 

17.
What will be the output of the program?

#include<stdio.h>
#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. 60, 6

 

18.
What will be the output of the program?

#include<stdio.h>
#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

 

19.
What will be the output of the program?

#include<stdio.h>
#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’


 

20.
What will be the output of the program?

#include<stdio.h>
#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

 

Visitor Counter

0056747