
MST
Program
24 Intro C++
Modify Program 23 so the middle names are chosen randomly
Like this…
In your concatenation loop where you create the new concatenated first[x]
for (x = 0; x < 5; ++x)
{
strcat(nam[x],
“ “)
do(
choice = random(5); //tentatively chooses a name
While(strcmp(middle[choice], “used”) = = 0); // keeps looping until it selects a non-used word
now CONCATENATE this middle[choice] to first[x]
immediately after using middle[choice]…replace it with
“used” strcpy(middle[choice], “used”)
}
Call Print(first) that prints the new combination. Don’t forget to have randomize(); (in stdlib.h)
OUTPUT: 6) Puff Sophie
Daddy 7) Britney C++
Spears 8) Bjarne Apple
Stroustroup 9) Bobby Oscard
Borland 10) Bill Texas Gates