/* * dec2bin.c * * Prompt the user for a positive number, then print the binary * representation of that number starting from the least-significant bit. */ #include int main() { unsigned dec; int i; scanf("%u",&dec); for (i=0; i < 8*sizeof(dec); i++) { // printf("Bit %2u: %u\n", i, dec%2); // dec /= 2; printf("Bit %2u: %u\n", i, (dec >> i) & 1); } return 0; }