Ruby Program to Check a Number Is Zero or Not Using the Zero?() Function

You are currently viewing Ruby Program to Check a Number Is Zero or Not Using the Zero?() Function

Ruby program to check a number is zero or not using the zero?() function

# Ruby program to check a number 
# is zero or not using the zero?() 
# function

num1 = 0;  
num2 = Complex(0,0);  
num3 = Complex(2,0);  

print "Num1: "  ,num1.zero?();
print "\nNum2: ",num2.zero?();
print "\nNum3: ",num3.zero?();
Num1: true
Num2: true
Num3: false

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