Created
December 28, 2012 04:40
-
-
Save kmandreza/4394552 to your computer and use it in GitHub Desktop.
Define four methods which correspond to the four basic arithmetic operations: add
subtract
multiply
divide
They should accept either integers or floating point numbers as input. divide should perform floating point division. For example, add(10,2) # => 12
subtract(10,2) # => 8
multiply(10,2) # => 20
divide(10,2) # => 5.0 (*not* 5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(num1, num2) | |
num1 + num2 | |
end | |
def subtract(num1, num2) | |
num1 - num2 | |
end | |
def multiply(num1, num2) | |
num1 * num2 | |
end | |
def divide(num1, num2) | |
num1 / num2 | |
end | |
add(10,2) | |
subtract(10,2) | |
multiply(10,2) | |
divide(10,2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment