2 d array of structs contain multiplication-division table


Question 1) Create a two dimensional array of structs which contain multiplication and division table of the rows and columns, starting at 1 instead of zero. This prevents us from causing a divide by zero error in the division table. The program needs to read the number of rows and columns from the user as command line arguments.

rows=atoi(argv[1]); cols=atoi(argv[2]);

For example, if you run your program with these command line arguments, ./prog 5 5, then your program must create a 5 by 5 matrix of structs and assign multiplication table to the mult variable in the struct and the division of the indices to the div variable in the struct. The mult variable needs to be an integral type (holding integers) and the div variable needs to be a floating-point type (holding fractional values).

Example:

struct mult_div_values {
int mult;
float div;
};

Your program needs to be well modularized with short functions, including the main, with 15 or less lines of code each. This means you would have a function which creates matrix of structs given the m x n dimensions, mult_div_values** create_table(int m, int n). You need to have functions that set the multiplication values and division values, void set_mult_values(mult_div_values **table, int m, int n) and void set_div_values(mult_div_values **table, int m, int n). Then, call functions to print the tables.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: 2 d array of structs contain multiplication-division table
Reference No:- TGS04861

Expected delivery within 24 Hours