In this program, we will create two variables and initialize them with some values. Then we will get the successor of a given number using the succ() library function.
The source code to get the successor of an integer number using the library function is given below. The given program is compiled and executed successfully.
# Ruby program to get the successor of an
# integer number using library function
num1 = 20;
num2 = -23
print "Successor of num1: ",num1.succ(),"\n";
print "Successor of num2: ",num2.succ(),"\n";
Output:
Successor of num1: 21
Successor of num2: -22
Explanation:
In the above program, we created two variables num1, num2 and initialized 20, -23 respectively. Then we got the successor of the given integer number using the succ() library function and printed the result.
Program/Source Code:
The source code to get the successor of an integer number using the library function is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created two variables num1, num2 and initialized 20, -23 respectively. Then we got the successor of the given integer number using the succ() library function and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer