#define f(g,g2) g##g2

main()

{

int var12=100;

printf("%d",f(var,12));

}

Answers were Sorted based on User's Feedback



#define f(g,g2) g##g2 main() { int var12=100; printf("%d&qu..

Answer / arnab maji

Hey Susie,

The ## is a concatenation operator,
When you pass the two arguments they get concatenated as

i/p --> f(g,g2) g##g2
o/p --> gg2

hence
f(var,12) will give us var12

effectively the printf statement gets modified as

printf("%d",f(var,12)); --> printf("%d",var12);

hence the output is 100 ie the value of var12.

Is This Answer Correct ?    56 Yes 3 No

#define f(g,g2) g##g2 main() { int var12=100; printf("%d&qu..

Answer / susie

Answer :

100

Is This Answer Correct ?    39 Yes 2 No

#define f(g,g2) g##g2 main() { int var12=100; printf("%d&qu..

Answer / vignesh1988i

the answer is 10012, the printf statement must be :

printf("%d",f(var12,12));

the number 12 will be concatenated by 100.

thank u.

Is This Answer Correct ?    7 Yes 17 No

Post New Answer

More C Code Interview Questions

main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?

2 Answers  


main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }

1 Answers  


what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }

3 Answers   Cisco, HCL,


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  






1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


How do you write a program which produces its own source code as its output?

7 Answers  


main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }

1 Answers  


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); } a. 2 b. 100 c. 4 d. none of the above

5 Answers   HCL,


Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number

2 Answers   Ace Info,


Categories