So I am new to C++, I started a few days ago. I have spent a lot of time learning it, maybe more than I should have in a few days lol. Anyways, I adopted some code that would roll a die twice and give a result. I decided to alter it some so that if the result was a prime number, you would 'win' and if it wasn't, you would lose and it would send you back through the program and you played until you got a prime number.
I decided to use what I learned from that to attempt to make a simple dice rolling program that would simply ask for the user to hit enter to run the script, and then it would roll the die for them once they hit enter. I made it so it ran through a while loop so that it would stay running so it could be used for more than one die roll.
I don't get an actual error when it prints, it all works fine except that I noticed that it will print the result, and then when I run it again it will print the same result, so if I hit enter once and get a 3, the second time I hit it I will get a 3 again, but if I hit it a third time I will get anything. I was wondering if someone would take a look at my code and maybe help me with a solution?
It's worth mentioning that it only seems to give me the same number twice like 75% of the time, but it still seems to frequent to be a coincidence. Also, this is my first time on stackoverflow and I could not figure out how to use the code input properly so I just added an image.
Thanks for any help I get, I can add additional information if asked for. There is a change that I have some '#include' functions that I don't need, I am not entirely sure. Any tips and advice is greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire