Q:

C++ Program To Check Number Is Positive Or Negative

0

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

Logic:-

 As we know that if a number is greater than 0 ( Zero ) Than number is positive and if a number is Less than 0 ( Zero ) than a number is Negative and else number is equal to zero then an entered number is Zero or equal to zero. Below is an explanation of the problem with an example. For this type of problem,  there maybe maximum 3 cases, all cases are given below.

Case 1:- Either number is greater than zero (Number is Positive)

Case 2:- Either number is less than zero (Number is Negative).

Case 3:- or number is equal to zero (Number is Equal to Zero).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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;

}

 

Output:

Enter The Number You Want To Check :

56

Number Is Possitive

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program To Check Upper Case Lower Case Digit A... >>
<< C++ Program To Find Character Is Vowel Or Not...