ProgrammingModerate

char s[] = "12345"; int v = 0; for (int i = 0; s[i]; i++) v = v * 10 + (s[i] - '0'); printf("%d", v); What is printed?

  1. A. 54321
  2. B. 15
  3. C. 12345
  4. D. 1234

Correct answer: C. 12345

Each character adds one more digit at the right, so the loop rebuilds the number 12345.

More C Programming questions

Exams that ask this topic