fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int num;
  7.  
  8. // Ask user for input
  9. std::cout << "Enter a number: ";
  10. std::cin >> num;
  11.  
  12. // Check the number
  13. if (num > 0) {
  14. std::cout << num << " is positive.";
  15. } else if (num < 0) {
  16. std::cout << num << " is negative.";
  17. } else {
  18. std::cout << "You entered zero.";
  19. }
  20.  
  21. return 0;
  22. }
  23.  
  24.  
Success #stdin #stdout 0s 5280KB
stdin
#include <iostream>

int main() {
    int num;

    // Ask user for input
    std::cout << "Enter a number: ";
    std::cin >> num;

    // Check the number
    if (num > 0) {
        std::cout << num << " is positive.";
    } else if (num < 0) {
        std::cout << num << " is negative.";
    } else {
        std::cout << "You entered zero.";
    }

    return 0;
}
stdout
Enter a number: You entered zero.