C code for the conversion of decimal to binary

#include<stdio.h>
int main(){
int dec,bin[64],i=0;
printf("enter decimal number");
scanf("%d",&dec);
while(dec>0){
bin[i]=dec%2;
i++;
dec=dec/2;

}
printf("binary number conversion is");
for(i;i>=0;i--){
printf("%d",bin[i]);

}
return 0;
}

 

 

OutputĀ 

LEAVE A REPLY