Computers and Technology
Computers and Technology, 24.05.2021 19:00, zoeycrew

Given n points P1(x1, y1, z1), P2(x2, y2, z2) . . . Pn(xn, yn, zn), implement the function centerPoint() that finds the center point using the following formula: C(xc, yc, zc)=(x1 +x2 +...+xn, y1 +y2 +...+yn, z1 +z2 +...+zn)
nnn
centerPoint() takes three arguments: a pointer to an array of struct point*, the number of points in the array, and a pointer to struct point center. It then calculates the coordinates of the center point (for all the points in the array) and stores it in struct point center. You may not use any square brackets ([]) in centerPoint().
struct point { float x;
float y;
float z; };
void centerPoint(struct point** points, int n, struct point* center) {
}
int main(void) {
struct point center;
struct point* points[100];
setPoints(points, 100);//Dynamically allocates the points
//and initializes the points
centerPoint(points, 100, &center);
printf("center point is (%f, %f, %f)\n, center. x, center. y, center. z); return 0;
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, lexirandall19
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
image
Computers and Technology, 24.06.2019 18:30, WATBOI01
What is the local portion of the e-mail address below? twrigley@gumchewer. biz a.) @ b.) biz c.) gumchewer d.) twrigley
Answers: 1
image
Computers and Technology, 25.06.2019 05:10, ethanmel21
Assume that two parallel arrays have been declared and initialized: healthoption an array of type char that contains letter codes for different healthcare options and annual cost an array of type int. the i-th element of annual cost indicates the annual cost of the i-th element of healthoption. in addition, there is an char variable, best2.write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. thus, if the values of healthoption are 'b', 'q', 'w', 'z' and the values of annualcost are 8430, 9400, 7050, 6400 your code would assign 'b' to best2 because 8430 is less than 9400 and is associated with 'b' in the parallel array. (we ignore 'w' and 'z' because we are considering only the first two options.)
Answers: 1
image
Computers and Technology, 25.06.2019 08:00, sierranowe2003
7. test average and grade write a program that asks the user to enter five test scores. the program should display a letter grade for each score and the average test score. write the following methods in the program: calcaverage: this method should accept five test scores as arguments and return the average of the scores. determinegrade: this method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: score letter grade 90-100 a 80-89 b 70-79 c 60-69 d below 60 f
Answers: 1
Do you know the correct answer?
Given n points P1(x1, y1, z1), P2(x2, y2, z2) . . . Pn(xn, yn, zn), implement the function centerPoi...

Questions in other subjects: