I'm trying to count down from 100 to zero and the max I want to subtract is 10; this is the code I've written but it always subtracts by the same amount every time I run it.
int main()
{
int total = 100;
srand(time(0));
int max = 10;
int randomNumber = rand() % max + 1;
while (total > 0)
{
total= total - randomNumber;
cout << total << endl;
}
}
Aucun commentaire:
Enregistrer un commentaire