find max number in c++ 3 nums code example
Example 1: max three values c++
int a = 1;
int b = 2;
int c = 3;
int m = std::max({a, b, c});
Example 2: 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;
}