cout <<"This Program will randomly pick a name"<<endl;
Sleep (2000);
srand((unsigned)time(0));
for(int index=0; index<20; index++)
random_integer = (rand()%20)+1;
Sleep (5000);
if (random_integer = 1)
{
cout <<" name 1"<<endl;
}
if (random_integer = 2)
{
cout <<" name 2"<<endl;
}
if (random_integer = 3)
{
cout <<"name 3"<<endl;
}
if (random_integer = 4)
{
cout <<"name 4"<<endl;
}
if (random_integer = 5)
{
cout <<" name 5"<<endl;
}
The if statements continue until 20. Later the "name 1, name 2".. stuff will just be a string. The problem with the current code is that the if statements don't work. No matter what the random number is, all of the names are displayed. Help please?