ProgrammingModerate
int x = 0; while (x < 3) x = x + 1; printf("%d", x); What is printed?
- A. 2
- B. 3
- C. 4
- D. 0
Correct answer: B. 3
The loop stops as soon as x is 3, so the printed value is 3.
More C Programming questions
- int count = 0; for (char c = 'a'; c <= 'z'; c++) if (c != 'e' && c != 'i' && c != 'o' && c != 'u') count++; printf("%d", count); What is…
- printf("%d", 3 > 2 ? 'Y' : 'N'); What is printed?
- char names[] = {"x", "yy", "zzz"}; printf("%zu", strlen(names[2])); What is printed?
- int a[4] = {4, 3, 2, 1}; int s = 0; for (int i = 0; i < 4; i++) s = s 10 + a[i]; printf("%d", s); What is printed?
- int i = 1; int s = 0; while (i <= 4) s += i++; printf("%d", s); What is printed?
- int n = 0; do { n += 2; } while (n < 7); printf("%d", n); What is printed?