I understand everything here, I coded it the only thing im not 100% sure on is
randomNumber = (rand() % 6) + 1 why do people use a modulus to get a number between 1 and 6. does it have something to do with RAND_MAX I tried displaying it its 32700 on my machine
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int randomNumber = 0;
int choice = 0;
srand(static_cast<unsignedint>(time(0)));
while (true)
{
std::cout << "\nPress 1 to roll dice and 2 to exit: ";
std::cin >> choice;
if (choice == 2)
{
break;
}
randomNumber = (rand() % 6) + 1;
std::cout << "\nYou rolled: " << randomNumber << "\n";
}
std::cout << "\n\nThank-You for rolling with us\n\n";
system("PAUSE");
return 0;
Yea thanks man I understand it now, also read that its a crappy way of generating random numbers. But it will do for now since I don't know of any other methods yet, reading up on them now.