ProgrammingHardGATE CS · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
int a[] = {1, 2, 3, 4, 5}, *p = a;
printf("%d", *(p + *(p + 2)));
}- A. 3
- B. 5
- C. 2
- D. 4
Correct answer: D. 4
*(p + 2) is 3, so the expression reads *(p + 3), which is 4.
More C Programming questions
- How many ways are there to place 3 non-attacking rooks on a 3 by 3 board? Compute with this program. c #include <stdio.h> int used[3]; int…
- In the sorted array {1, 3, 4, 4, 7}, what index is printed by this lower-bound search for key 4? c #include <stdio.h> int main(void) { int…
- How many of these statements are true for unsigned x = 5? Print the count from this program. c #include <stdio.h> int main(void) {…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {5, 6, 7}, p = a + 1; printf("%d", p[-1] + p + p[1]); }
- How many tilings does a 2 by 5 board have with 2 by 1 dominoes? Compute with this recursive program. c #include <stdio.h> int f(int n) {…
- What is printed? c #include <stdio.h> #include <stdlib.h> int v[] = {30, 10, 20}; int cmp(const void a, const void b) { int i = (const int…