Check Positive Or Negative Number using CPP

  1. Home
  2. Tutorials
  3. CPP
  4. CPP Programs
  5. If Else Statement
  6. Program

Source Code

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    // Variable Declaration for input
    int n;

   // Taking input in Variable n
    cout<<"Enter Number: ";

    if(n >= 0)
    return 0;


check positive or negative number using if else sstattement in C++Working

This program defined to check number either positive or negative. For this purpose we declare a variable n of type int to get input from user. After taking input we use selection statement to check.

Whether given number is greater than 0 or not.If number is greater than or equal to zero then it will print positive otherwise it will print negative.

Login to TRACK of Comments.