Can you tell me how to write a program that right-shifts an integer variable 4 bits? The program should print the integer in bits before and after the shift operation.
That’s too easy. C and C++’s >> operator will shift a value any number of bits.
i >>= 4;I’ll leave the printing part up to you, though.