#include<stdio.h>
#include<conio.h>
int main()
{
int dec,rem,ans=0;
printf("Enter the Decimal number\n");
scanf("%d",&dec);
while(dec>=2)
{
rem=dec%2;
dec=dec/2;
if(rem==0)
ans=ans*10;
else
ans=(ans*10)+1;
}
printf(" binary number is");
while(ans>0)
{
rem=ans%10;
ans=ans/10;
printf("%d",rem);
}
getch();
return 0;
}
this code is not working properly for example for 10 it gives 01, should be 1010