ProgrammingHardGATE CS · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
int *p = (int[]){1, 2, 3};
printf("%d", p[1] * p[2]);
}- A. 5
- B. 2
- C. 3
- D. 6
Correct answer: D. 6
The compound literal (int[]){1, 2, 3} has automatic storage that lasts for the enclosing block, so p[1] * p[2] = 2 * 3 = 6 is defined here.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { printf("%u", 1u << 31 >> 30); }
- What is printed? c #include <stdio.h> int main(void) { char w[] = {"ab", "cd", "ef"}; char p = w + 2; printf("%c%c", (p)[0], p[-1][1]); }
- What is printed? c #include <stdio.h> int main(void) { unsigned v = 0x01020304u, total = 0; for (int i = 0; i < 4; i++) { unsigned b = (v…
- What is printed? Compute the XOR of all integers from 1 to 1000 with this program. c #include <stdio.h> int main(void) { unsigned x = 0…
- How many monotone lattice paths go from the top-left corner to the bottom-right corner of a 4 by 4 grid of cells (moves only right or…
- How many iterations does this loop run? c #include <stdio.h> int main(void) { int c = 0; for (int i = 10; i >= 0; i -= 3) c++…