Check whether a number is positive or negative using if else in C++ Language

Introduction:  In the  previous article i explained How to swap two numbers without using temporary variable and Check whether a number is even or odd using if else statement and Program to get number of days in month,year using nested if and Program to calculate sum,average and division of marks and Find month name corresponding to number using switch case and Find greatest of three numbers using multiple if statement .
In this article i have written a program to check whether a number is positive or negative using if else statement in C++ Language. If the entered number is less than 0 (zero) then it is Negative number else it is Positive number.

Implementation: Let's understand by a program in C++ language.

#include<conio.h>
#include<iostream.h>
 main()
{
      int num;
      cout<<"Enter any number: ";
      cin>>&no;
      if(num>0)
       {
          cout<<"Number is positive";
       }
      Else
      {
         cout<<”Number is negative”;
      } 
      getch();
}

  • Now run the program using Ctrl+F9
Output:
First Run:
Enter any number: 20
Number is positive
Second Run:
Enter any number:-5
Number is negative

Now over to you:
"If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google+, Twitter, Linked in and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox . Stay tuned and stay connected for more technical updates."
Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..