Decimal to binary conversion

Decimal to binary  conversion -

‪#‎include<stdio.h>
#include<conio.h>
void main()
{int a,i=0,num[100];
printf("enter a number");
scanf("%d",&a);
if(a==0)
{printf("%d",a);
}
else
{while (a!=0)
{num[i]=a%2;
a=a/2;
i++;
}
while (i>0)
{i--;
printf("%d",num[i]);
}
}
getch();
return;
}

try out..........

Post a Comment

0 Comments