Assigning Name to Random Number?

Hello,
I need to assign a name to each random number. Only 3 numbers are being randomized: 1, 2 or 3. 1 should read out Sam, 2 should read out Billy, and 3 should read out Chris. For example, if it gives out 3 1 3, it should also show Chris Sam Chris. How would I go about doing this? Any help would be appreciated.

srand(time(0));
int random_integer;
int i;

for(i=0; i<3; i++)

{

random_integer = (rand()%3)+1;

cout << random_integer << endl;


}
lookup tables:

1
2
3
4
5
6
7
const char* names[3] = {"Sam","Billy","Chris"};

cout << names[0] << endl;
cout << names[1] << endl;
cout << names[2] << endl;

 // figure out the rest 
generate the random numbers between 0 to 2 and using the names array to do it.

Cheers,
Toshitaka
Topic archived. No new replies allowed.