ProgrammingHard

int n = 8, c = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j *= 2) c++; printf("%d", c); What is printed?

  1. A. 32
  2. B. 64
  3. C. 40
  4. D. 24

Correct answer: A. 32

The inner j takes 1, 2, 4, 8, which is 4 values, and the outer loop runs 8 times. 8 x 4 = 32.

More C Programming questions

Exams that ask this topic