Complete the code to print "Adult" if age is 18 or more.
int age = 20; if (age [1] 18) { std::cout << "Adult" << std::endl; }
The condition age >= 18 checks if age is 18 or more, so it prints "Adult" correctly.
Complete the code to print "Even" if the number is divisible by 2.
int number = 10; if (number [1] 2 == 0) { std::cout << "Even" << std::endl; }
The modulus operator % gives the remainder. If number % 2 == 0, the number is even.
Fix the error in the condition to check if score is less than 50.
int score = 45; if (score [1] 50) { std::cout << "Fail" << std::endl; }
The condition score < 50 correctly checks if the score is less than 50 to print "Fail".
Fill both blanks to print "Teenager" if age is between 13 and 19 inclusive.
int age = 15; if (age [1] 13 && age [2] 19) { std::cout << "Teenager" << std::endl; }
The condition age >= 13 && age <= 19 checks if age is between 13 and 19 inclusive.
Fill in the blanks to print "Grade A" if score is above 90, "Grade B" if score is above 80, else "Grade C".
int score = 85; if (score [1] 90) { std::cout << "Grade A" << std::endl; } else if (score [2] 80) { std::cout << "Grade B" << std::endl; } else { std::cout << "Grade C" << std::endl; }
The conditions use score > 90 and score > 80 to check if score is above 90 or 80, printing the appropriate grade.