ProgrammingHardProduct-company MCQ pattern
Compiled as C with 4-byte int, what is printed?
Compiled as C with 4-byte int, what is printed?
printf("%zu %zu", sizeof('A'), sizeof(char));- A. 4 4
- B. 1 1
- C. 2 1
- D. 4 1
Correct answer: D. 4 1
In C a character constant such as 'A' has type int, so sizeof('A') = sizeof(int) = 4. sizeof(char) is always 1. In C++ 'A' has type char and the output would be 1 1.
More C Programming questions
- What is printed? c int x = 1; { int x = 2; { x = 3; } printf("%d ", x); } printf("%d", x);
- With 4-byte int, what is printed? c int a[5]; printf("%td %td", (char )(a + 1) - (char )a, (char )(&a + 1) - (char )a);
- What is printed? c printf("%d", 010 + 0x10 + 10);
- What happens? c for (unsigned int i = 3; i >= 0; i--) printf("%u ", i);
- What is printed? c char s[] = "abc0def"; printf("%zu %zu", sizeof(s), strlen(s));
- What is printed? c printf("%zu", strlen("atbn"));