This question already has an answer here:
I'm using Microsoft Visual Studio C++ 2017
I'm fairly new to coding, and for one of my first projects I'm taking on making a dice software to simulate rolling dice. I've got all the code I need to roll one dice. But one thing I'm having trouble finding an answer to is how can I have the user input a variable (x) and have my RNG run (x) times and sum up all the results into one answer?
Example of what I'd like; Roll 3 times on a 6 sided dice, RNG would bring 3 results so ie 4, 3, 5 Next the program would combine those 3 results to one final # (so example's answer would be 12).
The RNG code i'm using is;
srand(time(NULL));
roll = rand() % sides + 1;
note: sides is a user entered variable.
Aucun commentaire:
Enregistrer un commentaire