Tuesday, August 10, 2010

DECIMAL TO BINARY CONVERSION

0 comments
#include<stdio.h>
#include<conio.h>
#include<math.h> 
void main()
{
int bin[10],i,j,N;
printf("Enter the decimal number:");
scanf("%d",&N);
i=0;
while(N>0)
{
bin[i]=N%2;
N=N/2;
i=i+1;
}
printf("The binary number is:");
for(j=i-1;j>=0;j--)
{
printf("%d",bin[j]);
}
getch();
}






Algorithm:

1.Start.
2.Read the decimal number.
3.Calculate the binary number using double-dabble method.
4.Print the binary equivalent of the decimal.
5.Stop.





Leave a Reply