ProgrammingModerate
int main(void) { int a[] = {1, 2, 3}; printf("%zu", sizeof a / sizeof a[0]); } What is printed?
- A. 12
- B. 1
- C. 3
- D. 4
Correct answer: C. 3
sizeof a is 12 bytes and sizeof a[0] is 4, so the division gives the element count, 3.
More C Programming questions
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t a[] = {200, 100, 50}; uint32t s = 0; uint8t t = 0; for…
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint32t m = 0x00A4u; for (int i = 0; i < 32; i++) if (m >> i &…
- What is printed? c #include <stdio.h> #include <stdlib.h> #include <string.h> int cmp(const void a, const void b) { return strcmp((const…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { int x = abs((const int )a), y = abs((const…
- This recursion counts the tilings of a 2 x n board with 2 x 1 dominoes. What is printed? c #include <stdio.h> int ways(int n) { if (n <=…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 3, 5, 7, 8, 9}; int i = 0, j = 6, c = 0; while (i < j) { int s =…