ProgrammingModerateTCS NQT · Infosys
What is sizeof "hi" in C?
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: B. 3
A string literal has type char array with room for the terminating null, so "hi" occupies 3 bytes. Its strlen is only 2.
More C Programming questions
- For unsigned a and b greater than 0 stored in uint32t, which test correctly detects that a b overflows?
- char words[] holds strings and must be sorted by length first and then alphabetically using qsort. Which comparator is correct?
- char buf[4]; int n = snprintf(buf, sizeof buf, "%d", 12345); What is n?
- uint8t x = 0xB7; uint8t y = x | (x + 1); What is y?
- The number of ways to tile a 2 x 6 board with 2 x 1 dominoes equals the number of binary tilings given by T(n) = T(n-1) + T(n-2) with T(1)…
- Intervals (1,4), (2,3) and (3,5) are stored as pairs in an array and qsort sorts them ascending by their second value. Which pair comes…