Machine-translated by Google. Questions are authored in English.
Top

Discussion

The type to use for a variable that must hold values from 0 to 200 in the least space is

  • A.uint16_t
  • B.unsigned int
  • C.uint8_t
  • D.int8_t

Answer: C

Correct answer: uint8_t

An unsigned 8-bit type holds 0 to 255, which covers the range in one byte. uint16_t and unsigned int would work but waste space, and int8_t reaches only 127 and would overflow. The fixed-width types from stdint.h are used precisely so the size is stated rather than assumed.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.