ProgrammingVery hardTCS NQT · Infosys
What is printed? Assume int is 4 bytes.
What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
int (*p)[3] = 0;
printf("%zu", sizeof *p);
}- A. 4
- B. 8
- C. 3
- D. 12
Correct answer: D. 12
*p has type int[3], which is 3 * 4 = 12 bytes. The null pointer is never dereferenced, because sizeof does not evaluate its operand.
More C Programming questions
- What is printed? Assume the array has space for 5 characters. c #include <stdio.h> int main(void) { char s[5] = "abcd"; printf("%zu"…
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 'A' == 65); }
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 0; x--; printf("%u", x >> 31); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 3}; printf("%d", (a + 1) + (1 + a)); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", (1 << 4) | 3 & 5); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", (int)(7 / 2 2.0)); }