// rolldice.cpp - demonstrates rand and srand functions by // selecting 2 random integers from 1 to 6 (pair of dice) // translated from C by cmc, 10/18/2015 #include #include #include using namespace std; int main() { int d1, d2; // seed the random generator with current system time srand(time(0)); /* find 2 random numbers, ranging from 1 to 6 */ d1 = 1 + rand() % 6; d2 = 1 + rand() % 6; cout << "rolled " << d1 << " and " << d2 << ", total " << d1+d2 << endl; return 0; }