ProgrammingModerate
int i = 1; int s = 0; while (i <= 4) s += i++; printf("%d", s); What is printed?
- A. 4
- B. 6
- C. 10
- D. 15
Correct answer: C. 10
The loop adds 1, 2, 3 and 4 before i reaches 5, so the sum is 10.
More C Programming questions
- int n = 0; do { n += 2; } while (n < 7); printf("%d", n); What is printed?
- unsigned char c = 0; c -= 1; printf("%d", c); What is printed?
- int m = 2147483647; printf("%d", m / 2); What is printed with a 32-bit int?
- How many subsets of the bit positions of mask 22 (binary 10110) are visited, counting the empty subset? Compute with this program. c…
- What is printed? c #include <stdio.h> int main(void) { unsigned a = 0xB6, b = 0x3C; printf("%u", a & ~b); }
- What is printed? This program tries every subset of {3, 5, 6} and prints the largest XOR of a subset (the empty subset counts as 0). c…