generate random number between range c++ no library code example
Example 1: c++ how to generate a random number in a range
min + ( std::rand() % ( max - min + 1 ) )
Example 2: c++ generate random numbers in range
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
for (int i = 0; i <= 10; i++)
{
int start = 3;
int end = 8;
cout << start + rand() % (end - start + 1);
}
}