Min and Max of Array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Min and Max of Array

I'm generating 100 random numbers. I want to print the min and max of the array by using a function for the min and a function for the max. I don't know what to put in these functions. #include<iostream> #include<cstdlib> #include<ctime> using namespace std; int maxInteger(int a[], int size); int minInteger(int a[], int size); int main() { int randomNumbers[100]; srand(time(0)); for (int i = 0; i < 100; i++) { randomNumbers[i] = rand() % 100 + 1; cout << randomNumbers[i] << " "; } cout << maxInteger(randomNumbers, 100); cout << minInteger(randomNumbers, 100); system("pause"); return(0); } int maxInteger(int a[], int size){ int val1; for (int i = 0; i < size; i++) { } } int minInteger(int a[], int size){ int val2; for (int i = 0; i < size; i++) { } }

29th Sep 2018, 10:30 PM
Krista Clark
Krista Clark - avatar
1 Answer
29th Sep 2018, 11:26 PM
Aleksander Szczepura
Aleksander Szczepura - avatar