+ 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; }
11 odpowiedzi
+ 2
female contains garbage value and male is not defined actually. What you want to do is take input gender as male or female.
+ 1
My coding are error
+ 1
and then share your code link
+ 1
Your else doesn't need () after it.
+ 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;
}
0
What's your question?
0
Is not a question but help me with this statement plz
0
run this code in code playground this is show you error
0
yes
0
to show male and female on screen
0
Thank you guys I got....