Arithmetic operations
  1. function inputno()
  2. {
  3.     echo -n "Enter the number 1:"
  4.     read n1
  5.     echo -n "Enter the number 2:"
  6.     read n2
  7. }
  8. function add()
  9. {
  10.     inputno
  11.     sum=`expr $n1 + $n2`
  12.     echo "Addition is $sum "
  13. }
  14. function sub()
  15. {
  16.     inputno
  17.     sub=`expr $n1 - $n2`
  18.     echo "Subtraction is $sub "
  19. }
  20. function mul()
  21. {
  22.     inputno
  23.     mul=`expr $n1 * $n2`
  24.     echo "Multiplication is $mul "
  25. }
  26. function div()
  27. {
  28.     inputno
  29.     div=`expr $n1 / $n2`
  30.     echo "Division is $div "
  31. }
  32. function ltu()
  33. {
  34.     echo -n "Enter Lower case string: "
  35.     read string
  36.     res1=${string^^}
  37.     echo "The upper case string is: $res1"
  38. }
  39. function utl()
  40. {
  41.     echo -n "Enter Upper case string: "
  42.     read string
  43.     res2=${string,,}
  44.     echo "The lower case string is: $res2"
  45. }
  46. echo "*********************************"
  47. echo "ARITHMETIC AND STRING OPERATIONS:"
  48. echo "*********************************"
  49. echo "1.ADDITION"
  50. echo "2.SUBTRACTION"
  51. echo "3.MULTIPLICATION"
  52. echo "4.DIVISION"
  53. echo "5.LOWER TO UPPER CASE STRING OPERATION"
  54. echo "6.UPPER TO LOWER CASE STRING OPERATION"
  55. echo "**********************************"
  56. echo -n "Enter your choice "
  57. echo -e
  58. read choice
  59. case $choice in
  60. 1)add;;
  61. 2)sub;;
  62. 3)mul;;
  63. 4)div;;
  64. 5)ltu;;
  65. 6)utl;;
  66. *)echo "!!!INVALID CHOICE!!!"
  67. esac
Parsed in 0.012 seconds