C++ examples for Data Type:Random
Using the Random Number Generator
#include <iostream> #include <time.h> #include <stdlib.h> using namespace std; int main(){ //from w w w. j av a 2 s .c o m // Always set a seed value. srand((unsigned int)time(NULL)); int RandomValue = rand() % 12; cout << "The random month number is: " << RandomValue + 1 << endl; return 0; }