Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. (25 points) For this question, do not worry about error checking. Assume all inputs to functions will be valid, and no malloc errors will
5. (25 points) For this question, do not worry about error checking. Assume all inputs to functions will be valid, and no malloc errors will occur. Ignore all trivial typos (e.g., missing :) in the code below and assume it will work as intended. (25 minutes) Given the following code that implements a 2-D Cartesian coordinate system: typdef struct { int x // x-axis position // y-axis position int val // value in that position } point_t int y int main(int argc, char** argv) { int rows = atoi (argv[1]) // number of rows in the 2-D array int cols = atoi(argv[2]) // number of columns in the 2-D array // create a 2D array of point_t* point_t*** my-grid init_2d_grid(&my-grid, rows, cols) // Print out the coordinate system print-grid(my-grid, rows, cols) } void print_grid(point_t*** my-grid, int rows, int cols) { for(int i = 0; i x, my-grid[i][j]->y, my-grid[i][j]->val) } printf(" ") } } 5. (25 points) For this question, do not worry about error checking. Assume all inputs to functions will be valid, and no malloc errors will occur. Ignore all trivial typos (e.g., missing :) in the code below and assume it will work as intended. (25 minutes) Given the following code that implements a 2-D Cartesian coordinate system: typdef struct { int x // x-axis position // y-axis position int val // value in that position } point_t int y int main(int argc, char** argv) { int rows = atoi (argv[1]) // number of rows in the 2-D array int cols = atoi(argv[2]) // number of columns in the 2-D array // create a 2D array of point_t* point_t*** my-grid init_2d_grid(&my-grid, rows, cols) // Print out the coordinate system print-grid(my-grid, rows, cols) } void print_grid(point_t*** my-grid, int rows, int cols) { for(int i = 0; i x, my-grid[i][j]->y, my-grid[i][j]->val) } printf(" ") } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started