Advertisement
Hiteshw11

If Else Statement In Ruby (Even/Odd)

Sep 27th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.19 KB | None | 0 0
  1. puts "Enter the Number"
  2. a=gets.chomp().to_i
  3. if a==0
  4.  puts "The number is 0"
  5. elsif a%2==0
  6.  puts "The number "+a.to_s+" is even"
  7. elsif a%2!=0
  8.  puts "The number "+a.to_s+" is odd"
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement