computing-fundamentals
C programs and question bank.
Monday, November 1, 2010
decimal to binary-C
#include
#include
void main()
{
int i,n,j,b[100];
clrscr();
printf("Enter a Number:");
scanf("%d",&n);
i=0;
while(n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
printf("\n\nBinary Equivalent:");
j=i-1;
for(i=j;j>=0;j--)
printf("%d",b[j]);
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment