unsigned char num;
unsigned char b0=1;
unsigned char b1=0;
unsigned char b2=1;
How to assign num to b2b1b0?
If we print num in binary at the end, it should be 101.
unsigned char num;
unsigned char b0=1;
unsigned char b1=0;
unsigned char b2=1;
How to assign num to b2b1b0?
If we print num in binary at the end, it should be 101.
Assuming b0, b1, and b2 are all bits within the num variable, and assuming little-endianness:
num = 1 | 4;
If you really needed to use the b* variables (I'm assuming you don't), You could do this:
unsigned char b0 = 1U;
unsigned char b1 = 2U;
unsigned char b2 = 4U;
unsigned char num = b0 | b2;