Skip to content
Related Articles
Open in App
Not now

Related Articles

std::uniform_real_distribution max() method in C++ with Examples

Improve Article
Save Article
Like Article
  • Last Updated : 17 Jun, 2019
Improve Article
Save Article
Like Article

The max() method of uniform_real_distribution class in C++ is used to get the maximum possible value that can be generated by this uniform_real_distribution.


result_type max() const;

Parameters: This method do not accepts any parameters.

Return Value: This method return the maximum possibly generated value in this uniform_real_distribution.


// C++ code to demonstrate
// the working of max() function
#include <iostream>
// for uniform_real_distribution function
#include <random>
using namespace std;
int main()
    double a = 10, b = 20.5;
    // Initializing of uniform_real_distribution class
    uniform_real_distribution<double> distribution(a, b);
    // Using max()
    cout << "Max value that can be generated"
         << " by this uniform_real_distribution: "
         << distribution.max() << endl;
    return 0;


Max value that can be generated by this uniform_real_distribution: 20.5


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!