Write a program as described below: --- A vector is a 1D array (like the ones we’ve been studying in class) with various

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write a program as described below: --- A vector is a 1D array (like the ones we’ve been studying in class) with various

Post by answerhappygod »

Write a program as described below:
---
A vector is a 1D array (like the ones we’ve been studying in
class) with various mathematical properties.
Consider a vector V of
length n:
V= (v1, v2,
v3, ... , vn)
The taxicab norm of V,
denoted ||V||1, is the sum of the
absolute values of the elements of the vector:
||V||1 = |v1| +
|v2| + |v3| + ... + |vn|
write a program that asks for the length of the vector (array)
allocates memory based on that length, inputs numbers into the
array(you may use a for loop and scanf),
calculates the taxicab norm of the vector (array) (you
may use a for loop and do the calculation inside the
loop) and finally outputs (prints) the taxicab norm. The
output value should be a float scalar.
You DON’T need comments, nor
idiotproofing (the length or memory allocation), and you may use
numeric literal constants anywhere you like.
You may use the fabs function from the C Standard Math
Library, which calculates the absolute value of a float scalar.
For example,
x = fabs(y);
assigns to a float variable named x the absolute value
of a float variable named y.
(This isn't necessarily exactly how you'll use
the fabs function in your code, and your variable names
will
probably WON'T be x nor y.)
Note that libraries that you need are stdio, stdlib and
math.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply