. 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; } |
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++.