How would i structure the min and max function for an array with a centennial control value
# include <iostream>
using.........
//Parameter list
int getMax(int arr[], int size)
int getMin (int arr[], int size)
int main()
{
//declare variable
int high= getMax (testScore, count);
cout<<" Max value is "<<high<<endl;
return 0;
}
int getMax(arr[], size)
{
int big= arr[0];
for (int i =1;i<size; i++)
{if arr[i].big= arr[i];
return big;
}
First off, please - wrap your code in [.code] [./code] tags(without dots).
Secondly, what is arr[i].big? :)
Your function should look like this:
1 2 3 4 5 6 7
int biggest = array[0];
for(every item in array from 1 to size-1)
{
if(current element is bigger then biggest)
set biggest to current element
}
return biggest;
Also, remember, that you're comparing items with == operator, but assigning with = operator.