Question: Question 1: Swapping Rows and Columns 1. Write a function, double_array(int row, int col), which returns a pointer to a struct called Double_Array. The Double_Array

 Question 1: Swapping Rows and Columns 1. Write a function, double_array(int

row, int col), which returns a pointer to a struct called Double_Array.

Question 1: Swapping Rows and Columns 1. Write a function, double_array(int row, int col), which returns a pointer to a struct called Double_Array. The Double_Array struct holds an uninitialized 2 dimensional double array, the row size, and the column size (accessed using .array,.rowsize, .colsize respectively). Note: From this point on, all functions will be referred to by their parameter signature o i.e. the types of the parameters will be given, but not their variable names. This gives you design control over the local variable names used in the function. However, in some cases parameter names are provided in the question. o In these cases, please use them. 2. Using the function rand_double you used in Lab Assignment 2, write a function randomize_array(struct Double_Array *, double, double) that takes a Double_Array struct, and two values of type double and initializes each element of the array in Double_Array to a randomly generated value between the two input values (inclusive) 3. Create a function called print_array that takes a Double_Array struct pointer and prints the array with each element displaying 1 decimal place, with the column elements lining up vertically. 4. Create a function called free_array() which takes a Double_Array struct pointer and frees the struct as well as the array within it. 5. Create a function called swap_rows(struct Double_Array *, int, int) where the two integer are row numbers to be swapped. Make sure each row number is valid according to the structure. If valid the rows are swapped and the function returns 1, otherwise the rows are not swapped and the function returns 0. Note: There are two possible approaches to swapping rows. One is faster to execute, and even to code. Bonus X mark if you implement the faster approach. Place your explanation as both a comment in the code and in your readme file as Q1a 6. Create a function called swap_columns(struct Double_Array *, int, int) where the two integer are column numbers to be swapped. Make sure each column number is valid according to the structure. If valid the columns are swapped and the function returns 1, otherwise the columns are not swapped and the function returns 0. 7. Create a main called a2_91.c that performs the following: Prints the following header Question 1 Creates a Double_Array struct that holds a 6 row by 9 column array Randomly initializes the array in the struct (you may choose the upper and lower bounds a and b) Prints out the array from the struct Randomly pick two rows to swap, and swaps them Inform the user which two rows were swapped and then print out the array Randomly pick to columns to swap, and swap them Inform the user which two columns were swapped and then print out the array Print 3 blank lines Make sure you free all malloced memory before exiting the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!