Arithmetic Operations Shell Hackerrank Solution

0

A mathematical expression containing +,-,*,^, / and parenthesis will be provided. Read in the expression, then evaluate it. Display the result rounded to 3 decimal places.



Constraints

All numeric values are <= 999.

Sample Input 1


5+50*3/20 + (19*2)/7

Sample Input 2


-105+50*3/20 + (19^2)/7

Sample Input 3


(-105.5*7+50*3)/20 + (19^2)/7

Sample Output 1


17.929

Sample Output 2


-45.929

Sample Output 3

22.146

Arithmetic Operations Shell Solution


read line;
printf "%.3f" $(echo "scale = 4; $line" | bc);


Note: This problem (Arithmetic Operations) is generated by HackerRank but the Solution is Provided by shouterFolk. This tutorial is only for Educational and Learning purposes.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !