ProgrammingHardGATE CS · Campus placements
#define CAT(a,b) a##b. After int CAT(num, 2) = 7; what does printf("%d", num2 * 2) print?
- A. 14
- B. 7
- C. 9
- D. num2
Correct answer: A. 14
The ## operator pastes the two tokens into one identifier, num2, before compilation. So num2 is the variable 7 and the output is 14.
More C Programming questions
- int a = 1 ? 2 : 3 ? 4 : 5; What is a?
- char p = "xyz"; char a[] = "xyz"; a[0] = 'Q'; printf("%s", a); What is printed?
- char s[4] = "abc"; What is sizeof s?
- Ackermann-style recursion: A(0,n) = n + 1 and A(m,0) = A(m-1,1), with A(m,n) = A(m-1, A(m,n-1)). What is A(1,5)?
- How many ordered ways are there to write 10 as a sum of parts equal to 1, 3 or 4, where the order of the parts matters?
- int arr[10]; What is sizeof(int[10]) / sizeof(int)?