Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Before we begin the chapter, let's review and practice C language problem: 2. Implement a main program and the following functions in C. You may

Before we begin the chapter, let's review and practice C language problem:

image text in transcribed

2. Implement a main program and the following functions in C. You may use floats or doubles for floating-point valued variables. (a) Create a C source file called vector.c. (b) Define a struct named Vector, a new C data type for 3-vectors, using stack arrays. (c) Write the following functions, which must take Vector, by pointer, for their vector arguments. Func- tions should return 0 if they run successfully and 1 if they produce an error. i. initialize: initialized the provided vector to 0 ii. inner-product: returns the inner (dot) product of two vectors iii. norm: returns the Euclidian norm of a vector iv. normalize: modifies a given vector to have length1, in place v. axpy: returns the result of the operation w = a*u+v vi. print: prints the contents of a vector in a useful way (d) Write a main program that uses the above functions (e) Compile your program so that the binary executable is named vector_01. 2. Implement a main program and the following functions in C. You may use floats or doubles for floating-point valued variables. (a) Create a C source file called vector.c. (b) Define a struct named Vector, a new C data type for 3-vectors, using stack arrays. (c) Write the following functions, which must take Vector, by pointer, for their vector arguments. Func- tions should return 0 if they run successfully and 1 if they produce an error. i. initialize: initialized the provided vector to 0 ii. inner-product: returns the inner (dot) product of two vectors iii. norm: returns the Euclidian norm of a vector iv. normalize: modifies a given vector to have length1, in place v. axpy: returns the result of the operation w = a*u+v vi. print: prints the contents of a vector in a useful way (d) Write a main program that uses the above functions (e) Compile your program so that the binary executable is named vector_01

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

2. What are your challenges in the creative process?

Answered: 1 week ago