OneBite.Dev - Coding blog in a bite size

add two numbers in Ruby

Code snippet on how to add two numbers in Ruby

 num1 = 5
 num2 = 2
 sum = num1 + num2
 puts sum

This code will add two numbers together. First, two variables, num1 and num2, are defined and given the values of 5 and 2 respectively. Then, the sum of the two variables is assigned to another variable, sum. Finally, the sum is displayed with the puts command. In this case, it will display 7, the sum of 5 and 2.

ruby