Decimal to Binary Conversion(int)


#include<stdio.h>
#include<conio.h>
int main()
{
int n,i,b,sum=0,t=1;
clrscr();
printf("enter any no. in decimal");
scanf("%d",&n);
while(n>0)
{
  b=n%2;
  sum=sum+b*t;
  n=n/2;
  t=t*10;
}
printf("\n the binary equivalent of the number is %d",sum);
getch();
return 0;
}

0 comments:

Post a Comment