C++ examples for Data Type:Random
Simulate the rolling of 10 dice
#include <iostream> #include <cstdlib> // Include support for randomizing. #include <ctime> // Include support for ctime. using namespace std; int main() {//from w w w . ja v a 2s . c o m srand(time(nullptr)); for (int i = 0; i < 10; ++i) { cout << (rand() % 6) + 1 << endl; } return 0; }