ProgrammingModerateTCS NQT · Infosys
uint8_t a = 200, b = 100; uint8_t c = a + b; What is the value of c?
- A. 300
- B. 45
- C. 44
- D. 0
Correct answer: C. 44
a and b are promoted to int, so a + b is 300. Converting 300 to uint8_t is well defined and reduces it modulo 256, giving 44.
More C Programming questions
- With uint32t x = 5u - 7u; what is the value of x?
- uint32t x = 0x00F0A8u; what is x & (0u - x) in hexadecimal?
- uint32t n = 0xB6u; the loop while (n) { n &= n - 1; count++; } runs with count starting at 0. What is count when the loop ends?
- uint16t v = 0xFFFFu; v = v << 4; What is v afterwards?
- For unsigned int n = 13, what is n ^ (n >> 1)? This is the binary-reflected Gray code of 13.
- What is the bitwise XOR of all integers from 1 to 10, that is 1 ^ 2 ^ 3 ^ ... ^ 10?