+ 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; }

6th Jun 2017, 4:21 AM
primex
primex - avatar
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 }
6th Jun 2017, 4:32 AM
jay
jay - avatar
+ 4
+1 on aklex answer: strings would be the way to go
6th Jun 2017, 4:28 AM
jay
jay - avatar
+ 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...
6th Jun 2017, 4:25 AM
aklex
aklex - avatar
+ 3
@aklex 😊 thank you.
6th Jun 2017, 4:28 AM
primex
primex - avatar
+ 3
@jay thank you bro 😊
6th Jun 2017, 4:29 AM
primex
primex - avatar
+ 3
@jay I've not learned that string lesson yet. I'm going to learn it today.
6th Jun 2017, 4:36 AM
primex
primex - avatar