Complete the code to check if a number is positive.
int num = 5; if (num [1] 0) { std::cout << "Positive" << std::endl; }
The condition num > 0 checks if the number is positive.
Complete the code to print "Even" if the number is even.
int num = 4; if (num % 2 [1] 0) { std::cout << "Even" << std::endl; }
The condition num % 2 == 0 checks if the number is even.
Fix the error in the if–else statement to print "Positive" or "Non-positive".
int num = -3; if (num [1] 0) { std::cout << "Positive" << std::endl; } else { std::cout << "Non-positive" << std::endl; }
The condition num > 0 correctly checks for positive numbers.
Fill both blanks to print "Adult" if age is 18 or more, otherwise "Minor".
int age = 20; if (age [1] 18) { std::cout << "Adult" << std::endl; } else { std::cout << "[2]" << std::endl; }
The condition age >= 18 checks if the person is an adult. Otherwise, print "Minor".
Fill all three blanks to print "Positive", "Negative", or "Zero" based on the value of num.
int num = 0; if (num [1] 0) { std::cout << "Positive" << std::endl; } else if (num [2] 0) { std::cout << "Negative" << std::endl; } else { std::cout << "[3]" << std::endl; }
The first condition checks if num > 0 (positive), the second if num < 0 (negative), else print "Zero".
