Random Number from a range

It is sometimes useful to have a program that generates a random number between a specific range of numbers in programming. In this example, we generate a random number 0 and 10. However, it can be modified to any range

#include <cstdlib>
#include  <ctime>
#include <cstdio>

int main() {

    int random_number, max_value;
    // Setting seed based on runtime
    srand(time(0));
    max_value = 10;
    random_number = rand() % 10;
    printf("The random number selected is: %d \n", random_number);
}

Below, we compile the program and run it a few times.

$ g++ main.cpp -std=c++17 -o random_number
$ ./random_number
The random number selected is: 3
$ ./random_number
The random number selected is: 7
$ ./random_number
The random number selected is: 4
$ ./random_number
The random number selected is: 1