Hello,

I am studying C in school and we have this book ANSI C written by Gary J. Bronson, which isnt very helpful..

So the question;

I am able to write a code which can change an integer in to whatever base I like but cant really do that with a decimal..(eg: 2.54) can someone please help me ??

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
int number,base,reminder,numbits=0,highestfactor,bit;
printf("please enter the decimal number:");
scanf("%d",&number);
printf("please enter the base the number will be converted to:");
scanf("%d",&base);
reminder=number;
while(reminder!=0)
{
reminder=reminder/base;
numbits++;
}
highestfactor=numbits-1;
int i=0;
while(i<numbits)
{
int pwr=pow(base,highestfactor);
bit=number/pow(base,highestfactor);
number=number%pwr;
printf("%d",bit);
highestfactor--;
i++;
}
system("pause");
getchar();
getchar();
return 0;
}