A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/algorithm/../ranges/../../cpp/header/../experimental/randint.html below:

std::experimental::randint - cppreference.com

template< class IntType >
IntType randint( IntType a, IntType b );

(library fundamentals TS v2)

Generates a random integer in the closed interval [a, b].

[edit] Parameters a, b - integer values specifying the range [edit] Return value

A random integer i in the closed interval [a, b], produced using a thread-local instance of std::uniform_int_distribution<IntType> invoked with the per-thread random number engine.

[edit]

If IntType is not one of short, int, long, long long, unsigned short, unsigned int, unsigned long, or unsigned long long, the program is ill-formed.

The behavior is undefined if a > b.

[edit] Example
#include <experimental/random>
#include <iostream>
 
int main()
{
    int random_number = std::experimental::randint(100, 999);
    std::cout << "random 3-digit number: " << random_number << '\n';
}

Possible output:

random 3-digit number: 273
[edit] See also reseeds the per-thread random engine
(function) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4