ProgrammingHardGATE CS · Campus placements

int n = -1; uint64_t u = (uint64_t)n; What is u?

  1. A. 18446744073709551615
  2. B. -1
  3. C. 0
  4. D. 9223372036854775807

Correct answer: A. 18446744073709551615

Converting a negative value to an unsigned type is defined as modular arithmetic: -1 plus 2^64 gives 18446744073709551615. This is the conversion used when a negative number is mixed into unsigned arithmetic.

More C Programming questions

Exams that ask this topic