Facebook
From nnnaser, 1 Month ago, written in Bash.
Embed
Download Paste or View Raw
Hits: 152
  1. echo "Enter first numbers: "
  2. read num1
  3.  
  4. echo "Enter second number: "
  5. read num2
  6.  
  7. echo "Enter third number: "
  8. read num3
  9.  
  10. # Check which number is the largest using if-else statements
  11. if [ $num1 -gt $num2 ] && [ $num1 -gt $num3 ];
  12. then
  13.     echo "The largest number is: $num1"
  14. elif [ $num2 -gt $num1 ] && [ $num2 -gt $num3 ];
  15. then
  16.     echo "The largest number is: $num2"
  17. else
  18.     echo "The largest number is: $num3"
  19. fi
  20.