Write a program that accepts a number as input, and prints just the decimal portion.
Example:
Enter a number: 15.789
Output:
0.789
Answers
Answered by
0
Explanation:
The below code is written in python language as there is no restriction about language.
Code:
System.in.println("Enter a number: %n" n);
System.out.printf("n %% 1= %.3f%n", n % 1);
System.out.printf("n - Math.floor(n) = %.3f%n", n - Math.floor(n));
System.out.printf("n - (int)n= %.3f%n", n - (int)n);
Code simulation :
Enter a number: 15.789
Output
n % 1= 0.789
n - Math.floor(n) = 0.789
n - (int)n= 0.789
Similar questions
Hindi,
6 months ago
Geography,
6 months ago
Social Sciences,
11 months ago
Math,
11 months ago
Math,
1 year ago