+ 3
I tried to make a simple code after learning c++ conditionals and loops. But I couldn't get the result as i want. Please help.😊
int male, female; int gender; cout << "Please enter your gender" << endl; cin >> gender; if ( gender == male ) { cout <<"go left" << endl; } if ( gender == female ) { cout << "go right"<< endl; }
6 odpowiedzi
+ 5
Also You wont need ints or strings for male and female.
#include <string>
string gender;
cin >> gender;
if(gender == "male") { etc etc }
+ 4
+1 on aklex answer: strings would be the way to go
+ 3
Male and female need to be set to a number. Like 0 for male and 1 for female. Or you could just stick to stings...
+ 3
@aklex 😊 thank you.
+ 3
@jay thank you bro 😊
+ 3
@jay I've not learned that string lesson yet. I'm going to learn it today.