Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3 : Complete the missing function read_vector below, which takes three pointers to float values as arguments. The function should read three floating point

Exercise 3: Complete the missing function read_vector below, which takes three pointers to float values as arguments. The function should read three floating point values from the user and store the result in the destination of the three pointers. If all values can be read successfully, the function will return 1. Otherwise (if any values cannot be read), the function will return 0. When the function works correctly, running the program will prompt the user to enter two vectors and then print those vectors back out. Do not modify the main function.

#include  int read_vector(float* px, float* py, float* pz){ //Your code here //(Don't forget the return statement) } int main(){ float x1, y1, z1; float x2, y2, z2; int success; printf("Enter a vector: "); success = read_vector(&x1, &y1, &z1); if (success == 0){ printf("Couldn't read the first vector, exiting... "); return 0; //Returning from main() will exit the program. } printf("Enter another vector: "); success = read_vector(&x2, &y2, &z2); if (success == 0){ printf("Couldn't read the second vector, exiting... "); return 0; } printf("The first vector is: %f %f %f ", x1, y1, z1); printf("The second vector is: %f %f %f ", x2, y2, z2); return 0; } 

Please fill in the code in the read_vector function, and use the scanf function to read the values.

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

What information remains to be obtained?

Answered: 1 week ago

Question

5. Tell how job experiences can be used for skill development.

Answered: 1 week ago

Question

4. Explain the characteristics of successful mentoring programs.

Answered: 1 week ago