ProgrammingHardCompetitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    int r0[2] = {1, 2}, r1[2] = {3, 4};
    int *rows[2] = {r0, r1};
    int *t = rows[0];
    rows[0] = rows[1];
    rows[1] = t;
    printf("%d", rows[0][1]);
}
  1. A. 4
  2. B. 2
  3. C. 3
  4. D. 1

Correct answer: A. 4

Swapping the row pointers makes rows[0] point at r1, so rows[0][1] is r1[1] = 4.

More C Programming questions

Exams that ask this topic