Bits and Bytes – Is 8 Bit and 1 Byte a Valid Question?

bitbooleanbyte

I saw these question in our school's past paper, and I'm wondering if this is a valid question.

How big is bool in C and C++?

A) 1 bit

B) 4 bit

C) 8 bit

D) 1 byte

What is the smallest unit of memory C or C++ use?

A) 1 bit

B) 4 bit

C) 8 bit

D) 1 byte

The answer to both are D, but I am thinking if this is inappropriate.

EDIT: 1 byte is not necessarily 8 bits on some systems. See this StackOverflow post.

Best Answer

AFAIK, no answers presented here are correct. The size of bool and _Bool is not constrained to be 1 byte (I seem to remember that there is a constraint in C which forces sizeof(_Bool)<=sizeof(short) which hasn't an equivalent in C++)

Related Topic