Ruby Program to Demonstrate the Arithmetic Operators

You are currently viewing Ruby Program to Demonstrate the Arithmetic Operators

Ruby program to demonstrate the arithmetic operators

# Ruby program to demonstrate the 
# arithmetic operators

num1 = 5
num2 = 2

num3 = num1 + num2
puts("Addition: ",num3)

num3 = num1 - num2
puts("Subtraction: ",num3)

num3 = num1 * num2
puts("Multiplication: ",num3)

num3 = num1 / num2
puts("Division: ",num3)

num3 = num1 % num2
puts("Remainder: ",num3)

num3 = num1 ** num2
puts("Exponential: ",num3)

Output

Addition: 
7
Subtraction: 
3
Multiplication: 
10
Division: 
2
Remainder: 
1
Exponential: 
25

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply