ADVERTISEMENT
ADVERTISEMENT

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

Ruby Example: Write a program to get the remainder of float numbers using library function.
Submitted by Nidhi, on December 15, 2021

Problem Solution:

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.

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 num1, num2 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.

Ruby Basic Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.