#include <stdio.h>
#include <limits.h>
// Bit shifting practice in C
void showbits(unsigned int x) {
for(int i = (sizeof(int) * 8) - 1; i >= 0; i--) {
(x & (1u << i)) ? putchar('1') : putchar('0');
}
printf("\n");
}
int main(void) {
printf("Char bit size is %u\n", CHAR_BIT);
unsigned int a = 2000;
int count = sizeof(unsigned int) * CHAR_BIT;
printf("bits of unsigned int is %d\n", count);
// Shows representation as bits are shifted.
for(int i = 0; i < count;i++) {
printf("(shifted %d bits) ", i);
showbits(a >> i);
}
return 0;
}