Hello All,
I am trying to generate an array which has random integers and pass this array to a function to be able to print random integers. The code I have written is as below. Can you help me about that?
Thanks
#include <iostream>
#include <ctime>
using namespace std;
void generate_array(int& f_array[]);
void print_array(int& p_array[]);
int main()
{
int num_arry[4];
generate_array(num_arry);
print_array(num_arry);
/*srand((unsigned)time(0));
int random_integer;
for(int index=0; index<5; index++){
random_integer = (rand()%1000)+1;
cout << random_integer << endl;
}
*/
}
void generate_array(int& f_array[])
{
srand((unsigned)time(0));
for (int index = 0; index<5; index++)
{
f_array[index]=(rand()%1000)+1;
}
}
void print_array(int& p_array[])
{
for(int i = 0; i<5; i++)
{
cout << "numbers" << p_array[i] << endl;
}
}