ProgrammingModerateTCS NQT · Accenture

What is printed? Assume int is 4 bytes and a pointer is 8 bytes.

What is printed? Assume int is 4 bytes and a pointer is 8 bytes.
#include <stdio.h>
int main(void) {
    printf("%zu", sizeof(int[10]) / sizeof(int *));
}
  1. A. 10
  2. B. 2
  3. C. 5
  4. D. 40

Correct answer: C. 5

sizeof(int[10]) is 40 bytes and a pointer is 8 bytes, so the quotient is 5. The 40 is the array size in bytes, which is not the count.

More C Programming questions

Exams that ask this topic