RosettaCodeData/Task/Arithmetic-Integer/Ruby/arithmetic-integer.rb

12 lines
361 B
Ruby
Raw Permalink Normal View History

2013-04-10 15:42:53 -07:00
puts 'Enter x and y'
2015-02-20 00:35:01 -05:00
x = gets.to_i # to check errors, use x=Integer(gets)
y = gets.to_i
2013-04-10 15:42:53 -07:00
puts "Sum: #{x+y}",
"Difference: #{x-y}",
"Product: #{x*y}",
2015-02-20 00:35:01 -05:00
"Quotient: #{x/y}", # truncates towards negative infinity
"Quotient: #{x.fdiv(y)}", # float
"Remainder: #{x%y}", # same sign as second operand
2013-04-10 15:42:53 -07:00
"Exponentiation: #{x**y}"