#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 *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }

1 Answers  


What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;

1 Answers  


main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }

1 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


What is your nationality?

1 Answers   GoDB Tech,






To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.

5 Answers   Amazon, Microsoft,


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details

2 Answers   TCS,


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

1 Answers  


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 function to find the depth of a binary tree.

13 Answers   Adobe, Amazon, EFI, Imagination Technologies,


Categories