We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Your code will not work for floating-point numbers. Try this,
5
1.2
1.8
2.0
2.2
2.8
Output should be 2.0 but your code will yeild 0.00 because bash doesn't support operation for Floating-point numbers. You'll need external tools such as awk, bc to get the job done.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compute the Average
You are viewing a single comment's thread. Return to all comments →
Your code will not work for floating-point numbers. Try this, 5 1.2 1.8 2.0 2.2 2.8
Output should be 2.0 but your code will yeild 0.00 because bash doesn't support operation for Floating-point numbers. You'll need external tools such as awk, bc to get the job done.