ProgrammingModerateTCS NQT · Infosys
char s[4] = "abc"; What is sizeof s?
- A. 3
- B. 4
- C. 5
- D. 1
Correct answer: B. 4
The array has four elements, which is the size declared, and the string fills three of them with a terminator in the fourth.
More C Programming questions
- 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?
- unsigned char c = 0x80; c >>= 1; printf("%d", c); What is printed?