when generating randomly 2 numbers in c++ between 1 and 3 what i have to do if i don't want the first nb to be == second nb | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

when generating randomly 2 numbers in c++ between 1 and 3 what i have to do if i don't want the first nb to be == second nb

8th Dec 2020, 9:21 AM
nano
3 Answers
+ 1
You can generate the first number, then put the random number generator in a loop, which runs until the generated number is not the same with the first.
8th Dec 2020, 9:37 AM
Ipang
+ 1
Use a "do...while" loop.
8th Dec 2020, 9:52 AM
rodwynnejones
rodwynnejones - avatar
+ 1
it worked thanks
8th Dec 2020, 3:06 PM
nano