ProgrammingModerate
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?
- A. 1234
- B. 4321
- C. 10
- D. 4
Correct answer: B. 4321
Each step shifts the running number one digit left and adds the next element, so the digits appear in array order: 4321.
More C Programming questions
- 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?
- 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); }