CJCoding With Joseph

Function: Average of Array

Write a function average(int arr[], int n) that returns the average of the n elements as a double. Use it on {1, 2, 4} and print the average to two decimals:

2.33

Cast the sum to double before dividing so the result is not truncated. Print with printf("%.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.