Finding the maximum element in a list:


For finding the maximum element in a list:

// C++ program to demonstrate the use of std::max

#include<iostream>

#include<algorithm>

using namespace std;

// Defining the binary function
bool comp(int a, int b)
{
 return (a < b);
}

int main()

{

  int a=10;
  int b=20;
  int c=30;
  int d=40;
  int e=50;

 // Finding the largest of all the numbers

 cout << std::max({a, b, c, d, e},comp) << "\n";

return 0;

Comments

Popular posts from this blog

For loop C++

VALENTINE DAY PROGRAME

Charecter & space founder in c program