Complete the code to check if the number is positive.
#include <iostream> using namespace std; int main() { int num = 10; if (num [1] 0) { cout << "Positive number" << endl; } return 0; }
The condition num > 0 checks if the number is positive.
Complete the else-if ladder to check if a number is negative.
#include <iostream> using namespace std; int main() { int num = -5; if (num > 0) { cout << "Positive" << endl; } else if (num [1] 0) { cout << "Negative" << endl; } else { cout << "Zero" << endl; } return 0; }
The condition num < 0 checks if the number is negative.
Fix the error in the else-if ladder condition to correctly check for zero.
#include <iostream> using namespace std; int main() { int num = 0; if (num > 0) { cout << "Positive" << endl; } else if (num [1] 0) { cout << "Zero" << endl; } else { cout << "Negative" << endl; } return 0; }
The condition num == 0 correctly checks if the number is zero.
Fill both blanks to complete the else-if ladder that prints the number's sign.
#include <iostream> using namespace std; int main() { int num = -3; if (num [1] 0) { cout << "Positive" << endl; } else if (num [2] 0) { cout << "Negative" << endl; } else { cout << "Zero" << endl; } return 0; }
The first condition checks if num > 0 (positive), the second checks if num < 0 (negative).
Fill all three blanks to create an else-if ladder that prints "Positive", "Negative", or "Zero" based on the number.
#include <iostream> using namespace std; int main() { int num = 0; if (num [1] 0) { cout << "Positive" << endl; } else if (num [2] 0) { cout << "Negative" << endl; } else if (num [3] 0) { cout << "Zero" << endl; } return 0; }
The conditions check if num > 0 (positive), num < 0 (negative), and num == 0 (zero).
