Logical operator (CPP)
Hello, I created a code by using logical operators and I wanted to create a code that would tell if you sleep enough or not depends on your age and your amount of sleep every 24 hours. The thing is that when I try it, it gives the wrong answers for example the output is: // What is your age 17 How long do you sleep everynight? 10 You don't sleep enough! // And I don't understand because I specified that: // if (age > 13 && age < 18 && sleep > 7) { cout << "You sleep enough!" << endl; // So please can someone help me please? #include <iostream> using namespace std; int main() { int age; int sleep; cout << "What is your age \n"; cin >> age; cout << "How long do you sleep everynight? \n"; cin >> sleep; if (age < 2 && sleep > 13) { cout << "You sleep enough!" << endl; } if (age < 2 && sleep < 14) { cout << "You don't sleep enough!" << endl; } if (age = 2 && sleep > 10) { cout << "You sleep enough!" << endl; } if (age = 2 && sleep < 11) { cout << "You don't sleep enough!" << endl; } if (age > 5 && age < 14 && sleep > 8) {