Q:

Ruby program to get the division and remainder using library function

belongs to collection: Ruby Basic Programs

0

In this program, we will create 2 variables and initialize them with some values. Then we will get the division and remainder using library function divmod().

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 division and remainder using the library function is given below. The given program is compiled and executed successfully.

# Ruby program to get the division and remainder 
# using library function

num1 = 20
num2 = 3

print "Division and Remainder: ",num1.divmod(num2),"\n";

Output:

Division and Remainder: [6, 2]

Explanation:

In the above program, we created two variables num1num2 and initialized 20, 3 respectively. Then we used the divmod() function to get division and remainder and printed the returned 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 check the given number is an odd n... >>
<< Ruby program to get the real part from a Complex n...