Decimal to Binary Conversion
======================
#include<stdio.h>
#include<conio.h>
void main()
{
int decimal,binary[20],i,temp,j;
i=0;
printf("Enter a Decimal Value to convert binary");
scanf("%d",&dec);
if(dec>0)
{
top:
binary[i]=decimal%2;
temp=decimal/2;
if(temp>0)
{
i++;
decimal=temp;
goto top;
}
}
else
{
printf("Binary of Given Decimal is; %d",0);
}
if(i!=0)
{
printf("Binary of Given Decimal is;\n");
for(j=i;j>=0;j--)
{
printf("%d",binary[j]);
}
}
}
No comments:
Post a Comment