Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

check if number is positive or negative in cpp

// positive negative or zero

#include <iostream>
using namespace std;

int main()
{
    int num;

    cout<< "Enter the number: ";
    cin >> num;

    if(num>0)
        cout<< "Positive";
    else if (num<0)
        cout<< "Negative";
    else
        cout<< "Zero";

    return 0;
}
 
PREVIOUS NEXT
Tagged: #check #number #positive #negative #cpp
ADD COMMENT
Topic
Name
7+5 =