Question: (b) (15 points) Given a Cartesian coordinate value (a, b), write a function that sum up all values from (0,0) to (a, b) inclusive, by

(b) (15 points) Given a Cartesian coordinate value (a, b), write a function that sum up all values from (0,0) to (a, b) inclusive, by traveling along the x-axis first, and then the y-axis. The header of the function should look like int sum_vals (point_t*** my-grid, int rows, int cols, int a, int b); rows and cols are the size of the grid, as before. (15 minutes) For example, given the following 3x3 grid from before and if you call the function (0,2,7) (1,2,9) (2,2,3) (0,1,8) (1,1,0) (1,1,0)|(2,1,2) (0,0,4) (1,0,8)|(2,0,3) as follows: int sum = sum vals(my-grid, rows, cols, 1, 2); then the value in sum should be 21: Starting from (0, 0, 4), you pass through (1, 0, 8), (1, 1, 0), ending up at (1, 2, 9), for a total sum of 4 + 8 + 0 + 9 = 21. (b) (15 points) Given a Cartesian coordinate value (a, b), write a function that sum up all values from (0,0) to (a, b) inclusive, by traveling along the x-axis first, and then the y-axis. The header of the function should look like int sum_vals (point_t*** my-grid, int rows, int cols, int a, int b); rows and cols are the size of the grid, as before. (15 minutes) For example, given the following 3x3 grid from before and if you call the function (0,2,7) (1,2,9) (2,2,3) (0,1,8) (1,1,0) (1,1,0)|(2,1,2) (0,0,4) (1,0,8)|(2,0,3) as follows: int sum = sum vals(my-grid, rows, cols, 1, 2); then the value in sum should be 21: Starting from (0, 0, 4), you pass through (1, 0, 8), (1, 1, 0), ending up at (1, 2, 9), for a total sum of 4 + 8 + 0 + 9 = 21
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
