I have this code and I want to be able to call it as a function. I looked up how, but am pretty confused and always get an error. Here is my code I want to make a function without global variables:
Code:srand(time(0)); //seed the random number
for(int i=1; i<=12; i++ ) //12 iterations
{
randomizer = rand() % 2;
if (randomizer == 0)
{
selection += ( selection == 8 ) ? -0.5 : 0.5;
}
else
{
selection += ( selection == 0 ) ? 0.5 : -0.5;
}
cout << selection << endl; //print out the 12
}
