I'm trying to get an idea of how this control syntax works :
Note * : This is part of my int. main function:
while(cin >> Options){
if(Options == 1){ //If I enter '1' here it will output: "aHi.Else."
cout << "a";
}else{
cout << "hi";
}
if(Options == 2){ //If I enter '2' here it will output: "hiaElse."
cout << "a";
}else{
cout <<"Hi.";
}
if(Options == 3){ //If I enter '3' here it will output: "hiHi.a"
cout << "a";
}else{
cout << "Else." << endl;
}
}
}
Why is it dripping over to else's and stuff? What's wrong with the syntax? I'm confused? How am I supposed to use multiple if's statements w/elses included? Can you give an example?
Aucun commentaire:
Enregistrer un commentaire