How do I print out only the decimal places for a number in C?
So here is the question:
Create a program that will read in a floating point number and output the decimal part of the number. e.g. given 3.14159, it will output .14159
I do not know the %f for only showing the decimal part of the number the user enters. What is it to only show the decimal places of a number?
Please explain your answer.
Code:
int main()
{
float n1;
printf("Please enter a number with 4 decimal places:\n");
scanf("%f", &n1);
printf("The decimal places you entered are %f .\n", n1);