In: Computer Science
Code in C-language programming description about convert binary number to decimal number.
#include
void main(){
auto int dec,bin;//declear veriable
int dec_to_bin(int bin);
printf("Enter a decimal number : ");//print information
scanf("%d",&dec);//input decimal number
bin=dec_to_bin(dec);
printf("The decimal number is = %d\n",dec);
printf("The bnunary number is = %d",bin);
}
int dec_to_bin(int d){
auto int b,r,y;
extern
b=0;y=1;
while(d>0){
r=d%2;d=d/2;
b=b+r*y;
y=y*10;
}
return(b);//return value of b
}