ProgrammingHardTCS NQT · Infosys
What is printed? Assume uint8t is 8 bits.
What is printed? Assume uint8_t is 8 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint8_t acc = 0;
uint8_t v[] = {200, 100, 50, 10};
for (int i = 0; i < 4; i++)
acc += v[i];
printf("%d", acc);
}- A. 360
- B. 104
- C. 88
- D. 0
Correct answer: B. 104
The running sum wraps modulo 256 at each addition, and the final value is 360 mod 256 = 104.
More C Programming questions
- What is printed? Assume uint32t is 32 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint32t a = 70000, b = 70000…
- What is printed? c #include <stdio.h> int main(void) { long long a = 1LL << 40; int b = (int)(a >> 20); printf("%d", b); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {4, 2, 5, 1}; for (int i = 0; i < 3; i++) printf("%d ", a[i] > a[i + 1] ?…
- How many pairs (i, j) with i < j have a[i] XOR a[j] equal to 5 for a = {1, 2, 3, 4}? Compute with this program. c #include <stdio.h> int…
- What is printed? c #include <stdio.h> struct N { int v; struct N nx; }; struct N rev(struct N h, struct N prev) { if (!h) return prev…
- What is printed? c #include <stdio.h> int main(void) { unsigned long long r = 1, b = 7; int e = 222; while (e) { if (e & 1) r = r b %…