fmax()
Published Oct 23, 2022Updated Dec 21, 2022
Contribute to Docs
The fmax()
function returns the larger of two arguments.
Syntax
fmax(x, y)
The parameters x
and y
are usually a numeric data type ranging from negative to positive INFINITY
. If one of the parameters is NaN
, then the other parameter is returned.
Example
The following example uses the fmax()
function to find the larger value between 3
and 5
:
#include <iostream>#include <cmath>int main() {double x = 3;double y = 5;double result;result = fmax(x, y);std::cout << "The larger value between " << x << " and " << y << " is " << result << "\n";}
This produces the following output:
The larger value between 3 and 5 is 5
Codebyte Example
The following example returns the larger value between -32.123
and -32.231
:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C++
Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.Beginner Friendly11 hours