Home Forums C Programming plzz help me out ……….. Re: Re: plzz help me out ………..

#3637
DeenaDeBernales
Participant

#include
#include
//#include
void main()
{
float bin;
float dec=0,multiplier=.5;
int temp,i=1,p; clrscr();
printf(“ENTER ANY BINARY NUMBER: “);
scanf(“%f”,&bin);
while(bin>0.0)
{
temp=(bin*10);

printf(“%dn”,temp);
bin=bin*10;
printf(“%fn”,bin);
bin=bin-temp;
printf(“nbin=%fn”,bin);
// p=pow(2,i);

dec=(dec+(multiplier*temp));
multiplier=multiplier*.5;
}
printf(“nnnTHE EQUIVALENT DECIMAL NUMBER IS: %f”,dec);
getch();
}

I have written this code btt this is not working.. for example suppose if i take .11 then after 2 nd time rotation of while loop the value of bin becomes 0.000000 bt when it goes to check with while loop that is (0.000000>0)it evalutes true ………which is not desired ……..how can i overcome this …………………..