. max() Function

The std::max() function is used to compare the two numbers and find the maximum among them. It is also defined inside the <algorithm> header file.

Syntax

max (a , b)

Parameters

  • a: First number
  • b: Second number

Return Value

  • This function returns the larger number among the two numbers a and b.
  • If the two numbers are equal, it returns the first number.

Example

C++




// C++ program to illustrate the max() function
#include <algorithm>
#include <iostream>
using namespace std;
  
int main()
{
  
    cout << max(7, 6);
  
    return 0;
}


Output

7

Useful Inbuilt Functions in C++

In-built functions in C++ are those functions that are part of C++ standard libraries. The purpose of inbuilt functions is to provide common and essential functionality that is frequently required in the programming. In this article, we will look at some of the commonly used inbuilt functions in C++.

Similar Reads

1. sqrt() Function

The sqrt() function is used to determine the square root of the value of type double. It is defined inside header file....

2. pow() Function

...

3. sort() Function

The pow() function is used to find the value of the given number raised to some power. This function is also defined inside header file....

4. find() Function

...

5. binary_search() Function

The sort() function is part of STL’s header. It is a function template that is used to sort the random access containers such as vectors, arrays, etc....

6 . max() Function

...

7 . min() Function

The find() function is also the part of STL library. This function is used to find some value in the given range. It can be used with both sorted and unsorted datasets as it implements....

8. swap() Function

...

9. tolower() Function

The binary_search() function is also used to find an element in the range but this function implements the binary search instead of the linear search as compared to the find function. It is faster than the find() function but it can only be implemented on sorted datasets with random access. It is defined inside the header file....

10. toupper() Function

...