This is a basic Cpp Program which checks whether a number is positive or negative.
A number is said to be POSITIVE if it is greater than 0 , NEGATIVE if less than 0.
PROGRAM:
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter any number : \t" << endl;
cin >> n ;
if(n == 0 )
cout << n << " is neither POSITIVE nor NEGATIVE" << endl;
else if( n > 1){
cout << n << " is POSITIVE number" << endl;
}
else
cout << n << " is NEGATIVE number" << endl;
return 0;
}
OUTPUT :
|
Cpp - Positive or Negative |
|
Cpp - Positive or Negative |
|
Cpp - Positive or Negative |
No comments:
Post a Comment