#include <stdio.h> int main(void) { int i; int dec; scanf("%d" , &dec); for(dec; dec > 0; dec = dec>>1)//shifting bits to the right by 1 is equivalent to dividing by power of 2. { if(dec & 1)//check least significant bit, if odd, then result is 1 printf("1"); else//if even then result is 0 printf("0"); } }
printf
char*
1 << index
index
dec & (1 << index)
dec
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)