โ Back to Functions/Methods
Question 292
Function: Average of Array
Function: Average of Array
Write a functionaverage(int arr[], int n)that returns the average of thenelements as adouble. Use it on{1, 2, 4}and print the average to two decimals: 2.33 Cast the sum todoublebefore dividing so the result is not truncated. Print withprintf("%.2f", ...).
Expected Output:
2.33
Topics:
Functions/Methods
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.