Simulate the rolling of 10 dice - C++ Data Type

C++ examples for Data Type:Random

Description

Simulate the rolling of 10 dice

Demo Code

#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;
}

Result


Related Tutorials