ProgrammingHardTCS NQT · Infosys
char *p = "xyz"; char a[] = "xyz"; a[0] = 'Q'; printf("%s", a); What is printed?
- A. Qyz
- B. xyz
- C. Qy
- D. QQz
Correct answer: A. Qyz
a is a modifiable array initialised from the string, so writing a[0] changes it to Qyz. The pointer p is not used in the output.
More C Programming questions
- 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)?
- What does printf("%d", 10 / 3 3 == 10) print?
- int x = 3; printf("%d", x << 2 | x >> 1); What is printed?