+ 1

i am confused, plz help me

#include <iostream> using namespace std; int main() { int age = 40; int gender; int female; cin>>age; switch(age){ case 40: cout<<"you have 40% chance live "; break; case 35: cin>>gender; if(female){ cout<<"you are mother"; } else(){ if(male){ cout<<"you are father"; } } case 20: cout<<"you are cute"; break; case 19: cout<<" you are cool"; break; case 16: cout<<"you are young"; break; case 14: cout<<"you are not kid"; break; case 10: cout<<"you are kid"; break; default: cout<<"sorry!YOU ARE DEATH"; } return 0; }

15th Jul 2017, 4:33 AM
Phub Thinley
Phub Thinley - avatar
11 Answers
+ 2
female contains garbage value and male is not defined actually. What you want to do is take input gender as male or female.
15th Jul 2017, 4:43 AM
Debakar Roy
Debakar Roy - avatar
+ 1
My coding are error
15th Jul 2017, 4:37 AM
Phub Thinley
Phub Thinley - avatar
+ 1
and then share your code link
15th Jul 2017, 4:41 AM
Yash Chaudhari
Yash Chaudhari - avatar
+ 1
Your else doesn't need () after it.
15th Jul 2017, 4:44 AM
Matt J
+ 1
So for your input you'd put the age space and write either male or female #include <iostream> #include <string> using namespace std; int main() { int age = 40; string gender; cin>>age; switch(age){ case 40: cout<<"you have 40% chance live "; break; case 35: cin>>gender; if(gender=="female"){ cout<<"you are mother"; } else{ if(gender=="male"){ cout<<"you are father"; } } break; case 20: cout<<"you are cute"; break; case 19: cout<<" you are cool"; break; case 16: cout<<"you are young"; break; case 14: cout<<"you are not kid"; break; case 10: cout<<"you are kid"; break; default: cout<<"sorry!YOU ARE DEATH"; } return 0; }
15th Jul 2017, 4:51 AM
Matt J
0
What's your question?
15th Jul 2017, 4:36 AM
Matt J
0
Is not a question but help me with this statement plz
15th Jul 2017, 4:37 AM
Phub Thinley
Phub Thinley - avatar
0
run this code in code playground this is show you error
15th Jul 2017, 4:40 AM
Yash Chaudhari
Yash Chaudhari - avatar
0
yes
15th Jul 2017, 4:41 AM
Phub Thinley
Phub Thinley - avatar
0
to show male and female on screen
15th Jul 2017, 4:44 AM
Phub Thinley
Phub Thinley - avatar
0
Thank you guys I got....
15th Jul 2017, 4:52 AM
Phub Thinley
Phub Thinley - avatar