#include <iostream>
int main() {
int num = 10;
if (num > 0) {
std::cout << "The number is positive." << std::endl;
} else if (num == 0) {
std::cout << "The number is zero." << std::endl;
} else {
std::cout << "The number is negative." << std::endl;
}
return 0;
}
- Include the iostream header file.
- Define the main function.
- Declare an integer variable
num
and initialize it with the value 10. - Begin the if statement with the condition
num > 0
. - If the condition is true, execute the block inside the curly braces, printing "The number is positive."
- If the condition in the if statement is false, move to the else if statement with the condition
num == 0
. - If the condition in the else if statement is true, execute the corresponding block, printing "The number is zero."
- If both the conditions in the if and else if statements are false, execute the block inside the else statement, printing "The number is negative."
- End the program by returning 0 from the main function.