+ 1
How to only show one answer at a time
My Problem is that when I run the program and select the option it shows two answers when I only need one for example when I select the 2 it shows the previous answers too
2 Answers
0
Here are the codes
#include <iostream>
#include<ctime>
using namespace std;
void showmenu(){
cout <<"****Movie Recommendator****"<<endl;
cout <<"Available Genre"<<endl;
cout <<"1. Horror"<<endl;
cout <<"2. Action"<<endl;
}
int main() {
int option;
do{
showmenu ();
cout <<"Select Genre: ";
cin >> option;
if (option = 1){
srand ( time (0) );
string Horror[3] ={"IT","Us","Bleach"};
int Randhorror = rand() % 3;
cout << Horror[Randhorror];
if (option = 2){
srand ( time (0) );
string a[3] ={"ITs","Use","Bleaches"};
int Randanime = rand() % 3;
cout << a [Randanime];
}
}
}while(option != 4);
return 0;
}
0
Hey there. Fix your if conditions. In both of them you used the "=" assignment operator instead of the "==" equals to operator.