ProgrammingHardGATE CS · TCS NQT

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 x = 3;
    for (int i = 0; i < 5; i++)
        x *= 3;
    printf("%d", x);
}
  1. A. 243
  2. B. 729
  3. C. 219
  4. D. 217

Correct answer: D. 217

After five multiplications by 3 the value is 3^6 = 729, and reducing modulo 256 gives 217. The unreduced 729 is not a possible uint8_t value.

More C Programming questions

Exams that ask this topic