I am prompted with the question as follows
- Write a program that prints dynamic arrays.
- The program creates an int 1D dynamic array of 3 elements and a float 2D dynamic array of 3 ROWS and 3 COLS.
- Initialize both arrays with random values.
- Both arrays will be printed separately in two separate functions
- void print_2d_array(float**);
- void print_1d_array(int*);"
I have created a code that will not produce any output. I am guessing the issue is in the initialization of the arrays, but I cannot figure it out. How do I get it to display the randomly generated numbers?
#include <iostream>
#include <iomanip>
using namespace std;
void print_2d_array(float**);
void print_1d_array(int*);
int main() {
srand(time(NULL));
int* arr[3];
float** arr_two[3][3];
for (int i = 0; i < 3; i++)
*arr[i] = rand() % 100;
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
**arr_two[j][k] = rand() % 100;
print_1d_array(*arr);
print_2d_array(**arr_two);
}
void print_2d_array(float** arr_two) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
cout << arr_two[i][j];
}
cout << endl;
}
void print_1d_array(int* arr) {
for (int i = 0; i < 3; i++)
cout << arr[i];
}