ProgrammingHardTCS NQT · Infosys
uint8_t acc = 0; uint8_t a[3] = {250, 3, 7}; for each element, acc += a[i]; What is acc after all three additions?
- A. 260
- B. 0
- C. 4
- D. 3
Correct answer: C. 4
After 250 and 3 the running value is 253. Adding 7 gives 260, which is stored in uint8_t as 260 mod 256 = 4.
More C Programming questions
- int a[] = {3, 5, 6, 9}; int pre[5]; pre[0] = 0, and pre[i] = pre[i-1] ^ a[i-1] for i = 1..4. What is pre[4] ^ pre[1]?
- void f(int a) { sizet n = sizeof a / sizeof a[0]; ... } is called as f(arr) where int arr[4]. What is true about n?
- unsigned int n = 0u; int i = 0; if (i < n - 1) printf("loop"); What is printed?
- Is the C standard guaranteed to remove stack frames of tail-recursive calls, so that deep tail recursion cannot overflow the stack?
- int a[6] = {1, 2, 3, 4, 5, 6}; int p = a, q = a + 5; while (p < q) { int t = p; p++ = q; q-- = t; } What is a[1] afterwards?
- uint8t x = 0xB4; What is the lowest set bit of x, computed as x & (uint8t)-x?