Advertisement
Hiteshw11

Add 3 numbers taking user input in ruby

Sep 26th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.28 KB | None | 0 0
  1. puts "Enter the first number"
  2. a=gets.chomp().to_i
  3. puts "Enter the second number"
  4. b=gets.chomp().to_i
  5. c=a+b  # c variable becomes int because a and b are int
  6. puts "The addition of "+ a.to_s + " and " +b.to_s+ " is " +c.to_s # need to convert everything to string before printing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement