Ruby Program to Check the Given Number Is an Even Number Using Library Function

You are currently viewing Ruby Program to Check the Given Number Is an Even Number Using Library Function

Ruby program to check the given number is an EVEN number using library function

# Ruby program to check the given number is 
# an EVEN number using library function

num1 = 20
num2 = 3

if num1.even?()
    print "num1 is an EVEN number\n";
else
    print "num1 is an ODD number\n";
end

if num2.even?()
    print "num2 is an EVEN number\n";
else
    print "num2 is an ODD number\n";
end
num1 is an EVEN number
num2 is an ODD number

Ranjith Kumar

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

Leave a Reply