We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Linux Shell
  3. Bash
  4. Comparing Numbers
  5. Discussions

Comparing Numbers

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 235 Discussions, By:

recency

Please Login in order to post a comment

  • divyangoza7998
    2 weeks ago+ 0 comments
    read A
    read B
    if (($A > $B)); then
        echo X is greater than Y;
    elif (($A < $B)); then   
        echo X is less than Y;
    else
        echo X is equal to Y;
    fi
    
    0|
    Permalink
  • nayakanurag078
    3 weeks ago+ 0 comments
    read a 
    read b 
    (( a > b )) && echo "X is greater than Y  " && exit 0
    (( a == b )) && echo "X is equal to Y   " && exit 0
    (( a < b )) && echo "X is less than Y  " && exit 0
    
    0|
    Permalink
  • Krishna_Nani
    1 month ago+ 0 comments

    read X read Y

    if [ Y ]; then echo "X is less than Y" elif [ Y ]; then echo "X is greater than Y" else echo "X is equal to Y" fi

    0|
    Permalink
  • MasterAless
    2 months ago+ 0 comments
    #!/usr/bin/bash
    
    read X
    read Y
    
    # it is important to set the spaces between the numbers.
    if [ $X -lt $Y ]; then
        echo "$X is less than $Y"
    elif [ $X -gt $Y ]; then
        echo "$X is greater than $Y"
    else
        echo "$X is equal to $Y"
    fi
    
    0|
    Permalink
  • TarangKr
    2 months ago+ 0 comments
    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
    
    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy