Advertisement
STANAANDREY

pb heat 2

Feb 23rd, 2024
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.25 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 3 ]; then
  4.     echo "Usage: $0 <num1> <op> <num2>!"
  5.     exit 1
  6. fi
  7.  
  8. case $2 in
  9.     +) res=$(($1+$3));;
  10.     -) res=$(($1-$3));;
  11.     \*) res=$(($1*$3));;
  12.     /) res=$(($1/$3));;
  13.     *)
  14.         echo "invalid op"
  15.         exit 1;;
  16. esac
  17.  
  18. echo = $res
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement