I made this loop, but how do I make it so it doesn't output numbers below 0 or over 10?
It asks for a user to input a number 1-10 earlier and then randoms a 0 or 1. If a 0 then add 0.5, if a 1 then subtract 0.5. Thanks I am just stuck after messing with it for hours. Pretty new to C++
Code:srand(time(0)); //seed the random number for(int i=1; i<=12; i++) //12 iterations starting from 1 { randomizer = rand() % 2; if (randomizer == 0) { selection = selection + 0.5; cout << selection << endl; } else { selection = selection - 0.5; cout << selection << endl; }



LinkBack URL
About LinkBacks


