ProgrammingHardGATE CS · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
int m[3][5];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 5; j++)
m[i][j] = i * 5 + j;
int *f = &m[0][0];
printf("%d", f[13]);
}- A. 8
- B. 15
- C. 10
- D. 13
Correct answer: D. 13
The array is row major with rows of five ints, so flat index 13 is m[2][3], which holds 2 * 5 + 3 = 13.
More C Programming questions
- What is printed? c #include <stdio.h> void swap(int a, int b) { int t = a; a = b; b = t; } int main(void) { int x = 1, y = 2; int p = &x…
- What is printed? c #include <stdio.h> void rev(int a, int l, int r) { while (l < r) { int t = a[l]; a[l] = a[r]; a[r] = t; l++; r--; } }…
- What is printed? c #include <stdio.h> int main(void) { static const unsigned char t[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4}; unsigned x =…
- How many times does the value change between neighbours in {1, 1, 2, 2, 2, 3, 1}? Compute with this program. c #include <stdio.h> int…
- How many numbers from 1 to 100 are divisible by 4 but not by 3? Compute with this program. c #include <stdio.h> int main(void) { int c =…
- What is printed by this memoised recursion? The static memo table starts with every entry zero, and calls counts each call to f. c…