Hello, I am trying to create a program that will read a double precision floating point number and output only the decimal part of the number given. For example, Input: 2.39 Output: 0.39
I am struggling to overcome this hurdle. So far I can only make it output 0.00.
Code:
int main (void){
double amount = 0.0;
int Loonies = 0;
printf("Please enter the amount to be paid: $");
scanf("%if",&amount);
printf("Loonies required: %i", amount);
printf(", balance owing $%0.2f", amount);
return 0;
}
Any help or suggestions would be greatly appreciated!