+ 1
I’m a beginner
The first question is to write a method in Ruby that takes in a number as a parameter and prints “This number is even” if the number is even or “This number is odd” If it’s odd.
3 odpowiedzi
+ 2
you can do this with if statements, for example, you make an input field then you can say if the number is 1,3,5,7, etc, the output will be odd and same for even
+ 2
Make an initial attempt and share your code. If you get stuck people can help.
0
thank you! here is what I have initially:
def even?(x)
puts "The number is even"
end
even?(8)
def odd?(x)
puts "The number is odd"
end
odd?(7)