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]);
}- A. 4
- B. 2
- C. 3
- 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
- What is printed? The reverse of the binary digits of 13 (1101) is taken as an integer. c #include <stdio.h> int main(void) { unsigned x =…
- How many occurrences of the two-letter string "ab" are in "abcabab"? Count them with this program. c #include <stdio.h> int main(void) {…
- What is printed? c #include <stdio.h> int main(void) { int c = 0; switch ('b') { case 'a': c++; case 'b': c += 10; case 'c': c += 100…
- How many nodes are at depth 2 in a perfect binary tree of depth 3 (the root is depth 0)? The program counts them recursively. c #include…
- What is printed? Each struct has an int a and an int b. c #include <stdio.h> #include <stdlib.h> struct P { int a, b; }; int cmp(const…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 11, y = x & (x + 1); printf("%u", y); }