Arithmetic Operations HackerRank Solution

Hello Programmers, In this post, you will know how to solve the Arithmetic Operations HackerRank Solution. This problem is a part of the HackerRank Linux Shell Series.

Arithmetic Operations HackerRank Solution
Arithmetic Operations HackerRank Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Problem

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

Sample Input 1
5+503/20 + (192)/7

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

Sample Input 3
(-105.57+503)/20 + (19^2)/7

Sample Output

Sample Output 1
17.929

Sample Output 2
-45.929

Sample Output 3
22.146

Arithmetic Operations HackerRank Solutions

read x
printf "%.3f\n" `echo "$x" | bc -l` 

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

Next: Compute the Average HackerRank Solution

Sharing Is Caring

Leave a Comment