#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

What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }

1 Answers  


/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }

4 Answers  


how to return a multiple value from a function?

2 Answers   Wipro,


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

2 Answers  


find simple interest & compund interest

2 Answers  






main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error

1 Answers   HCL,


What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30

0 Answers  


main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }

1 Answers  


int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


how can i search an element in an array

2 Answers   CTS, Microsoft, ViPrak,


Categories