i have tried on several different occasions to write a program that would ask a question or give a scenario and based on the amount input display different phrase. what happens though is that several phrases will end up being displayed because it fits into both circumstances. for example in this instance i have two phrases being triggered because the input is larger than both 10 and 18. how can i fix this issue? is there a way to have it output something if the variable input is between say 10 and 18 rather than greater than or equal to 10.
Code://whats's your age? #include <iostream> using namespace std; using std::endl; int main() { cout<< "how old are you"; int age; cin>> age; if (age>=10) { cout<< "1"; } if (age<=9) { cout<< "2"; } if (age>=18) { cout<< "3"; } cin.ignore(); cin.get(); return 0; }