ProgrammingHardTCS NQT · Infosys
char names[3][5] = {"ab", "cde", "f"}; What is strlen(names[1]) + sizeof names[2]?
- A. 6
- B. 8
- C. 3
- D. 5
Correct answer: B. 8
strlen(names[1]) is 3 for "cde", and sizeof names[2] is the full row length of 5 bytes. Their sum is 8. Rows of a 2D char array always have the declared width.
More C Programming questions
- A recursive function sums decimal digits: int ds(int n) { return n < 10 ? n : n % 10 + ds(n / 10); }. What is ds(98765)?
- How many 1 bits does 0xDEADBEEF have in binary?
- uint32t value = (uint32t)-1; printf("%d", value == 0xFFFFFFFFu); What is printed?
- How many index pairs i < j in the array {3, 5, 3, 5, 7} satisfy a[i] XOR a[j] == 0?
- How many integers from 1 to 30 are multiples of 8?
- A circular buffer of size n = 5 steps back from index 0 with (idx + n - 1) % n. What index results?