HackerRank - Comparing Numbers
April - 25/2025Problem:
Given two integers, X and Y, identify whether:
- - X is less than Y
- - X is greater than Y
- - X is equal to Y
# Input
- 5
- 2
# Output
- X is greater than Y
# Solution
read X
read Y
if ((X < Y)); then
echo "X is less than Y"
elif ((X > Y)); then
echo "X is greater than Y"
else
echo "X is equal to Y"
fi
# Solution_01
read x;
read y;
if [ $x -gt $y ]; then
echo "X is greater than Y";
elif [ $x -lt $y ] ; then
echo "X is less than Y";
else
echo "X is equal to Y";
fi