Finding the maximum value of an array of randomized numbers. What is wrong with it? thanks

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;

int findLarger(int thearray[20], int &largervalue);

int main(){
int thearray[20];
int largervalue = (-1001);
findLarger(thearray, largervalue);

cout << "The largest value in the array is:" << " " << largervalue << endl;
system("pause");
}

int findLarger(int thearray[20], int &largervalue){

srand(unsigned(time(NULL)));
for (int i = 0; i < 20; i++){

int thearray = rand() % 2001 + (-1000);

cout << "The randomized array is:" << " " << thearray << endl;

}
for (int j = 0; j < 20; j++){
if (thearray[j] > largervalue){
largervalue = thearray[j];

}
}
return largervalue;
}
Last edited on
Topic archived. No new replies allowed.