subtract two numbers in ruby

You can subtract two numbers in Ruby by using the '-' operator. Here is an example:

main.rb
a = 10
b = 5
c = a - b
puts c # Output: 5
42 chars
5 lines

In this example, we define two variables a and b and then subtract b from a using the - operator. The result is stored in variable c which is then printed to the console using puts.

gistlibby LogSnag