Saturday, October 15, 2016

Addition of Two Numbers in Ruby

A very simple program that I wrote using Ruby as my programming language that will ask the user to give two numbers and then our program will compute for the sum of the two numbers.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing


print "\n\n";
print "Sum of Two Numbers in Ruby"
print "\n\n";
print "enter number 1 : ";
val1 = gets;
print "enter number 2 : ";
val2 = gets;

val1 = val1.to_i
val2 = val2.to_i

sum = sum.to_i

sum = (val1 + val2)

print "\n\n";
puts "The sum of #{val1} and #{val2} is #{sum}."
print "\n\n";
print "End of Program";
print "\n\n";


No comments:

Post a Comment