ProgrammingHardGATE CS · Campus placements
What does printf("%d", sizeof('a') == sizeof(int)) print?
- A. 1
- B. 0
- C. depends on the platform
- D. 1 only on 8-bit char systems
Correct answer: A. 1
Character constants have type int in C, so sizeof('a') equals sizeof(int) on every conforming platform, and the comparison prints 1.
More C Programming questions
- char words[] = {"one", "two", "three"}; char pp = words + 1; printf("%s", pp + 1); What is printed?
- int a[2][3] = {{1, 2, 3}, {4, 5, 6}}; int p = &a[0][0]; printf("%d", p[4]); What is printed?
- int a[] = {10, 20, 30}; printf("%d", a + 2); What is printed?
- int a[] = {10, 20, 30}; printf("%d", 2[a] - a[1]); What is printed?
- How many subsets of {1, 2, 3, 4, 5, 6} have an element sum equal to 7?
- In a 3 x 3 grid, a walker can move only right or down from the top-left corner to the bottom-right corner. How many distinct paths exist?