#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,d,i;
d=0;
i=0;
clrscr();
printf("Enter any number:");
scanf("%d",&n);
while(n!=0)
{
d=d+(n%10)*pow(2,i);
n=n/10;
i=i+1;
}
printf("\n\n The decimal number is %d",d);
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
int n,d,i;
d=0;
i=0;
clrscr();
printf("Enter any number:");
scanf("%d",&n);
while(n!=0)
{
d=d+(n%10)*pow(2,i);
n=n/10;
i=i+1;
}
printf("\n\n The decimal number is %d",d);
getch();
}
No comments:
Post a Comment