Program In C To Convert Decimal Number To Binary Number

Leave a Comment
#include<math.h>
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
printf("\nEnter the number to convert into binary number:");
scanf("%d",&n);
int r=0;
int s=0,i=0;
while(n!=0)
{
r=n%2;
n=n/2;
s=s+pow(10,i)*r;
++i;
}
printf("\nTHE BINARY EQUIVALAENT OF IS %d",s);
getche();
return 0;
}

0 comments: