Skip to content

Instantly share code, notes, and snippets.

@kmandreza
Created December 28, 2012 04:40
Show Gist options
  • Save kmandreza/4394552 to your computer and use it in GitHub Desktop.
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)
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