Hello Programmers, In this post, you will know how to solve the Comparing Numbers HackerRank Solution. This problem is a part of the HackerRank Linux Shell Series.
One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.
Problem
Given two integers, X and Y, identify whether X < Y or X > Y or X = Y.
Exactly one of the following lines:
– X is less than Y
– X is greater than Y
– X is equal to Y
Input Format
Two lines containing one integer each (X and Y, respectively).
Constraints
–
Output Format
Exactly one of the following lines:
– X is less than Y
– X is greater than Y
– X is equal to Y
Sample Input
Sample Input 1
5
2
Sample Input 2
2
2
Sample Input 3
2
3
Sample Output
Sample Output 1
X is greater than Y
Sample Output 2
X is equal to Y
Sample Output 3
X is less than Y
Comparing Numbers HackerRank Solutions
#!/bin/bash read X read Y if (( $X > $Y )) then echo "X is greater than Y" fi if (( $X == $Y)) then echo "X is equal to Y" fi if(( $X < $Y)) then echo "X is less than Y" fi
Note: This problem (Comparing Numbers) is generated by HackerRank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.