How to only show one answer at a time | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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

25th Nov 2022, 3:54 AM
Christian Jay Verano
Christian Jay Verano - avatar
2 Respuestas
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; }
25th Nov 2022, 4:14 AM
Christian Jay Verano
Christian Jay Verano - avatar
0
Hey there. Fix your if conditions. In both of them you used the "=" assignment operator instead of the "==" equals to operator.
25th Nov 2022, 6:26 AM
Tumelo Diale
Tumelo Diale - avatar