Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago