Answers for "c++ random int from 1 to 50"

C++
7

c++ random number between 1 and 10

cout << (rand() % 10) + 1<<" ";
Posted by: Guest on November-22-2020
2

c++ random number 0 to 1

#include <iostream>
#include <string>
#include <random>

int main() {
    std::mt19937 gen (123);
    std::uniform_real_distribution<double> dis(0.0, 1.0);
    double x = dis(gen);
    std::cout << x << std::endl;
}
Posted by: Guest on May-11-2021

Code answers related to "c++ random int from 1 to 50"

Browse Popular Code Answers by Language