Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a function lengths that takes two parameters: a three - column matrix of floats ( 2 D array ) and an integer that indicates

Define a function lengths that takes two parameters: a three-column matrix of floats (2D array) and an integer that indicates the number of rows in the matrix. Return a pointer to an array of floats allocated on the heap where each element of the returned array is the length of the vector defined by the corresponding row in the matrix.
For example, given the matrix:
012
345
678
900
the lengths function should return {2.24,7.07,12.21,9.0}.
The length of a vector can be found by the Pythagorean Theorem:
len([a,b,c])= sqrt(a2+b2+c2)
Note: the matrix parameter is not an array of pointers-to-float (float *m[3]), but a matrix with rows of size 3(float m[][3]).
Answer:(penalty regime: 0%)

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

More Books

Students also viewed these Databases questions

Question

Group Size and Communication

Answered: 1 week ago

Question

Understanding Group Roles

Answered: 1 week ago