ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
int v[] = {3, 9, 4};
int *p = v;
int s = 0;
while (p < v + 3) s += *p++ * 2;
printf("%d", s);
}- A. 16
- B. 32
- C. 24
- D. 36
Correct answer: B. 32
Each element is doubled and added, so the total is 2 * (3 + 9 + 4) = 32.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { printf("%c", 'Z' - 'A' + 'a'); }
- What is printed? c #include <stdio.h> #include <stdlib.h> int nd(int n) { int c = 0; for (int d = 1; d <= n; d++) if (n % d == 0) c++…
- How many binary strings of length 4 have exactly two 1s? The program counts them recursively. What is printed? c #include <stdio.h> int…
- What is printed? c #include <stdio.h> int v[] = {1, 2, 3}; int cnt(int i, int s) { if (i == 3) return s % 2 == 0; return cnt(i + 1, s) +…
- What is printed? c #include <stdio.h> int used[3]; int count(int d) { if (d == 3) return 1; int t = 0; for (int i = 0; i < 3; i++) { if…
- What is printed? Assume uint8t is 8 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 0x0F; uint8t r =…