How to Write a program that accepts a number as input, and prints just the decimal portion.
Answers
Answered by
0
Answer:
3.444444
Explanation:
float a,b;
printf ("enter the code for.......");
Answered by
0
Following are the program accepts a number as input, and prints just the decimal portion. is given below.
Explanation:
Following are the program in C language
#include <stdio.h> // header file
#include <math.h> // header file
int main() // main function
{
float r1; // vaiable declaration
printf("Enter the number :\n");
scanf("%f", &r1); // Read input
float t=r1-floor(r1); // calculated the decimal value
printf("The decimal portion is %f .\n", t); // display
return 0;
}
Output:
Enter the number :
34.88
The decimal portion is 0.880001
Following are the description of program .
- Declared a variable r1 as float type.
- Read the input by user .
- With the floor function we determine the decimal portion .The definition of floor function is in the math.h header file. we calculated the decimal partition in t variable.
- Finally print the t variable .
Learn More:
- brainly.in/question/14901093
Similar questions