hey guys so we are doing our project in c++ class. It is called "Color Game" there is an imaginary die with 6 sides and with diff colors. I don't know how to call randomly a string array. So for example I declared:
int color[] = {"Blue", "Red", "Green", "White", "Orange", "Yellow"};
I want 1 random name of the color from the array to be the output. I just don't know what code I will use. I'm just an amateur in c++.
Also, we need to display different color name when we have for example:
char answer;
cout<<"The first color is: " <<color1;
cout<<"want to play again (y/n)? ";
cin>>answer;
if (answer = 'y')
{
cout<<"The second color is: " <<color2;
}
and when we run the program, the 2 colors are randomly picked from the array.
This is just a sample of how will be the output should be. please help me in random calling arrays. thanks!
Aucun commentaire:
Enregistrer un commentaire