largest/smallest array values c++ code example
Example: find min and max in array c++
#include<iostream>
using namespace std;
public void getMax_MinValue(int arr[])
{
int max, min;
max = arr[0];
min = arr[0];
for (int i = 0; i < sizeof(arr); i++)
{
if (max < arr[i])
max = arr[i];
else if (min > arr[i])
min = arr[i];
}
cout << "Largest element : " << max;
cout << "Smallest element : " << min;
}