Q:

Ruby program to get the remainder of float numbers using library function

belongs to collection: Ruby Basic Programs

0

In this program, we will create two variables and initialize them with some values. Then we will get the remainder of float numbers using library function modulo.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to get the remainder of float numbers using the library function is given below. The given program is compiled and executed successfully.

# Ruby program to get the remainder of 
# float numbers using library function

num1 = 22.34;
num2 = 3.0;

print "Remainder is: ", num1.modulo(num2);

Output:

Remainder is: 1.3399999999999999

Explanation:

In the above program, we created two variables num1num2 and initialized them with 22.34, 3.0 respectively. Then we got the remainder of after division using built-in function modulo() and printed the result.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Ruby Basic Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Ruby program to compare numbers and strings using ... >>
<< Ruby program to get the magnitude of the given num...