+ 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

9th Feb 2019, 5:03 PM
EmAminudin
2 Antworten
+ 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*/ }
9th Feb 2019, 5:14 PM
Jomari Pantorilla
Jomari Pantorilla - avatar
+ 1
Thx for your answer :)
9th Feb 2019, 5:23 PM
EmAminudin