multiply two numbers in ruby

In Ruby, you can use the * operator to multiply two numbers together.

Here's an example of multiplying two numbers in Ruby:

main.rb
a = 3
b = 5
c = a * b
puts c  # Output: 15
43 chars
5 lines

In this example, a is assigned the value 3, b is assigned the value 5, and c is the product of a and b. The puts method is used to output the value of c.

You can also perform multiplication directly in the puts statement:

main.rb
puts 3 * 5  # Output: 15
25 chars
2 lines

gistlibby LogSnag