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
Computer Science,
5 months ago
Accountancy,
5 months ago
Social Sciences,
10 months ago
Math,
10 months ago
Math,
1 year ago