Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function called sumAndAverage. It should take in an array of numbers and return the sum and average of the array in that order.
Write a function called sumAndAverage. It should take in an array of numbers and return the sum and average of the array in that order. For example:
[s a] = sumAndAverage([3 2 3 2]) %should return 10 and 2.5
[s a] = sumAndAverage([5 -5 2 8 0]) %should return 10 and 2
[s a] = sumAndAverage([]) %should return 0 and 0
You can use Built-in functions.
Create a vector, then invoke your function like this:
>>Arr=[3 2 3 2]
>>[s a]=sumAndAverage(Arr)
Note: the function has only one parameter. It is a vector
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started