Okay, well, I copied the script from the tutorial on the site (the enter your age tutorial one), and I added more phrases. The problem was that if you entered, "2", as your age, you would get all the answers for the other ages. Let me post the code so you know my problem.
Code:#include <iostream> using namespace std; int main() { int age; cout<<"Please input your age: "; cin>> age; cin.ignore(); if ( age <= 25 ) { cout<<"You are pretty young!\n"; } if ( age <= 50 ) { cout<<"You are middle aged\n"; } if ( age <= 100 ) { cout<<"You are old\n"; } else if ( age <= 125 ) { cout<<"You are really old\n"; } else { cout<<"Stop lying you moron and tell me your age\n"; } cin.get(); }
That was what I originally changed, until this...
The problem is I don't know boolean, or how to fix this problem so please help me, a lonely n00b, out.Code:#include <iostream> using namespace std; int main() { int age; cout<<"Please input your age: "; cin>> age; cin.ignore(); if ( age <= 25 ) { cout<<"You are pretty young!\n"; } if ( age <= 50 && >= 26 ) { cout<<"You are middle aged\n"; } if ( age <= 100 && >= 51 ) { cout<<"You are old\n"; } else if ( age <= 125 && >= 101 ) { cout<<"You are really old\n"; } else { cout<<"Stop lying you moron and tell me your age\n"; } cin.get(); }