C Programs RSS
Friday, December 30, 2011
Binary To Decimal
#include
#include
#include
void main()
{
int n,i,d,sum=0;
clrscr();
printf("Enter a Number:");
scanf("%d",&n);
for(i=1;n!=0;i++)
{
d=n%10;
sum=sum+(pow(2,i)*d);
n=n/10;
}
printf("Num Is:%d",sum);
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment