+ 2
What causes input C++ problem? And how to fix choice outside of the conditions??
I made a code for first time. But if you enter another numbers of gender (e.g. 3), your choice will be heading number of 2. And it was an error in this code. How to fix it? My Code HERE : https://code.sololearn.com/cb23U4iCiBQk/?ref=app
2 Answers
+ 3
you can use an if-else if-else statement or a switch statement.
like say:
if(x==1) { /*code*/ }
else if(x==2) { /*code*/ }
else { /*code, maybe add an error message*/ }
or
switch(x) {
case 1: /*code*/ break;
case 2: /*code*/ break;
default: /*your error message*/
}
+ 1
Thx for your answer :)