Decimal to Binary
#include
#include
int main()
{
printf ("Convert Decimal number to Binary number\n");
int num,base=1, Binary=0;
printf ("Input Decimal number:");
scanf ("%d",&num);
int temp=num;
while (temp){
int rem= temp%2;
temp=temp/2;
Binary += rem*base;
base= base*10;
}
printf ("\nThe Binary number is:%d\n",Binary);
return 0;
}
Result ouput
0 Comments