So I have to write a program that will count the cubic values of two-dimensional array elements. The main program should load matrix dimensions (the user must re-enter it until the values are between 2 and 10). Then dynamically allocate the memory for the two-dimensional array.
#include <iostream>
constint r = 100;
constint c = 100;
usingnamespace std;
int main()
{
int r, c;
do {
cout<<"Size of rows and columns in between [2,10]"<<endl;
cin>>r>>c;
} while (r<2 || r>10 || c<2 || c>10);
int ** mat;
mat = newint*[r];
for(int i = 0; i < r; i++)
mat[i] = newint[c];
for(int j = 0; j < r; j++)
for(int i = 0; i < r; i++)
mat[i][j] = 0;
return 0;
}
Now I have to call the function where the array values will be loaded (the user inputs), call a function that calculates the cubic values of the matrix values, save them into a newly dynamically allocated two-dimensional array and return the pointer to that new two-dimensional field.
Here is a start to how you can declare you dynamic 2D array and pass it around for processing in functions. One function you will need and see results straight away is a display() function using appropriate parameters.