Monday, 2 March 2015

C++ Program To Check Number Is Positive Or Negative

Problem :- Write A C++ Program To Check Number Is Positive Or Negative .Number should be Entered Through User Then program Print the Output .

Logic :- As we know that if number is greater than 0 ( Zero ) Than number is positive and if number is Less than 0 ( Zero ) than number is Negative and else number is equal to zero than entered number is Zero .

See Also :- C Program To Check Number Is Positive Or Negative

Solution :- 

#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter The Number You Want To Check : \n";
cin>>a;

if(a<0)
{
cout<<"Number Is Negative:\n";
}
else if(a>0)
{
cout<<"Number Is Possitive:\n";
}
else
{
cout<<"You Enter Zero :\n";
  }
return 0;

}

See Also :- Java Program To Check Number Is Positive Or Negative

Output:-

C++ Program To Check Number Is Positive Or Negative

No comments:
Write comments

Recommended Posts × +