program to convert given decimal number into binary.



main()
{
unsigned int i,j, k
clrscr();
printf("Enter a number in decimals");
scanf("%d",&j);
printf("Binary equivalent of decimal is");
for(i = 0;i<10;i++)
{
k= 1 <<(15-i);
if((j && k) = 0)
printf ("0") else
printf("1");
}
}





if input is 2044
out put is 0000011111111100

if input is 98

output is 0000000001100010


No comments:

Post a Comment