• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Nov 20th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # !/bin/bash
2.
3. if [ "\$1" = "-n" ] && [ "\$2" != "" ] && [ "\$3" = "" ]
4. then
5. res=`echo - \$2 | bc`
6. echo "Result : \$res"
7.
8. elif [ "\$1" = "-i" ] && [ "\$2" = "" ] && [ "\$3" = "" ]
9. then
10. echo "Enter Choice :"
12. echo "2. Multiplication (a*b)"
13. echo "3. Subtraction (a-b)"
14. echo "4. Division (a/b)"
15. echo "5. Negation (-a)"
17.
18. case \$ch in
19.   1)echo "Enter Two numbers: "
22.         res=`echo \$a + \$b | bc`
23.   ;;
24.   2)echo "Enter Two numbers: "
27.         res=`echo \$a \* \$b | bc`
28.   ;;
29.   3)echo "Enter Two numbers: "
32.         res=`echo \$a - \$b | bc`
33.   ;;
34.   4)echo "Enter Two numbers: "
37.         res=`echo "scale=2; \$a / \$b" | bc`
38.   ;;
39.   5)echo "Enter One number: "
41.         res=`echo - \$a | bc`
42.   ;;
43. esac
44. echo "Result : \$res"
45.
46. elif [ "\$1" = "-a" ] && [ "\$2" != "" ] && [ "\$3" != "" ]
47. then
48. res=`echo \$2 + \$3 | bc`
49. echo "Result : \$res"
50.
51. elif [ "\$1" = "-d" ] && [ "\$2" != "" ] && [ "\$3" != "" ]
52. then
53. res=`echo "scale=2; \$2 / \$3" | bc`
54. echo "Result : \$res"
55.
56. elif [ "\$1" = "-s" ] && [ "\$2" != "" ] && [ "\$3" != "" ]
57. then
58. res=`echo \$2 - \$3 | bc`
59. echo "Result : \$res"
60.
61. elif [ "\$1" = "-m" ] && [ "\$2" != "" ] && [ "\$3" != "" ]
62. then
63. res=`echo \$2 \* \$3 | bc`
64. echo "Result : \$res"
65.
66. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top