Ruby program to get the predecessor of an integer number using library function

bookmark


num1 = 20;
num2 = -23

print "Predecessor of num1: ",num1.pred(),"\n";
print "Predecessor of num2: ",num2.pred(),"\n";

 


Output:

Predecessor of num1: 19
Predecessor of num2: -24