Wednesday, August 13, 2014

Decimal to Binary Program

Simple program to Convert a decimal number to binary. If you have doubts, let me know
#include <stdio.h>
main()
{
int num,count,temp;
printf("Enter the number");
scanf("%d",&num);
for(count=31;count>= 0;count--)
{
temp=num>>count;
if(temp&1)
printf("1");
else
printf("0");
}
}

No comments:

Post a Comment