// bits.cpp // sample problem that shows how to set bits in char and int variables #include using namespace std; int main() { // recipe on how to put bits into a character // we will put 8 bits into character c // we will put bits: 01100001, which corresponds to // the ASCII code for character "a" unsigned char c; // it is very important to be unsigned // so that 11111111 is not understood as a negative number!!! int a[] = {0,1,1,0,0,0,0,1}; // initializing array with 8 integers c = 0; for (int i=0; i<8; i++) { c = c << 1; // shifts all bits of c one position to the left c += a[i]; // adds number a[i], which now becomes the right most bit of c } cout<< "c = "<