The source code to check given number is an integer or not is given below. The given program is compiled and executed successfully.
# Ruby program to check the given
# number is an integer or not
num1 = 12.34;
num2 = -100;
num3 = 400;
print "Num1: " ,num1.integer?;
print "\nNum2: ",num2.integer?;
print "\nNum3: ",num3.integer?;
Output:
Num1: false
Num2: true
Num3: true
Explanation:
In the above program, we created three variables num1, num2, num3 initialized with 12.34, -100, 400 respectively. Then we checked given numbers are integer or not using integer? and printed the result.
Program/Source Code:
The source code to check given number is an integer or not is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created three variables num1, num2, num3 initialized with 12.34, -100, 400 respectively. Then we checked given numbers are integer or not using integer? and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer