HackerRank - Arithmetic Operations
April - 25/2025Problem:
A mathematical expression containing +,-,*,^, / and parenthesis will be provided. Read in the expression, then evaluate it. Display the result rounded to 3 decimal places.
# Input
- 5+50*3/20 + (19*2)/7
- -105+50*3/20 + (19^2)/7
- (-105.5*7+50*3)/20 + (19^2)/7
# Output
- 17.929
- -45.929
- 22.146
# Solution
read expression
printf "%.3f" $(echo $expression | bc -l)