C++ Program to Check if a Number is Positive, Negative or 0














































C++ Program to Check if a Number is Positive, Negative or 0



Description:
Input a number from the user and check the number by these equation:
i)if number >0
  then it is a positive number
ii)if number <0
  then it is a negative number
iii)if number ==0
  then it is a positive number
Program:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  cout<<"Enter a number";
  cin>>a;
  if(a>0)
    cout<<"Positive Number";
  else if(a<0)
    cout<<"Negative Number";
  else
    cout<<0;

}
Output:
Enter a number 5 Positive Number 

Enter a number -5 Negative Number 
Enter a number 0


More Articles of MAYANK KUMAR:

Name Views Likes
C++ program to remove all leaf nodes from the binary search tree 964 18
C++ program for counting sort Algorithm 823 17
C++ Program to Find Numbers Divisible by Another Number 1260 18
C++ program to find K%u2019th largest element in binary search tree 871 19
C++ Program to Find ASCII Value of Character 784 18
C++ Program to Add Subtract Multiply Divide 852 24
C++ program to check if a binary tree is binary search tree or not 1120 15
C++ Program to Add Two Numbers 846 16
C++ program to convert a binary search tree to a Binary Tree 965 26
C++ Program to Get Input from User 824 18
C++ Program to Calculate Average of Numbers 825 14
C++ Program to convert Celsius to Fahrenheit 733 16
C++ Program to Find the Sum of Natural Numbers 711 17
C++ Program to find square root of a number 748 19
C++ Program to Read a File 810 19
C++ Program to Check if a Number is Positive, Negative or 0 834 20
C++ program to construct binary search tree from given inorder traversal 937 19
C++ Program to Find LCM 736 11
C++ program to convert binary tree to binary search tree 1230 19
C++ Program to Calculate Average Percentage 1139 15
C++ program to reverse a path in binary search tree using queue 1007 19
C++ Program to Convert Decimal to Binary Using Recursion 2457 14
C++ Program to Find Factorial of Number Using Recursion 833 17
C++ Program to Delete Files 916 15
C++ program to find second largest element in binary search tree 1067 17
Difference between binary tree and binary search tree 881 26
C++ Program to Print Prime Numbers 929 20
C++ Program to Find Square Root of Number 772 15
C++ program to find K%u2019th smallest element in binary search tree 840 24
C++ Program to Find HCF or GCD 936 17
C++ programs for Bucket sort Algorithm 795 14
C++ Program to Print String 867 18
C++ program to check if each internal node of a binary search tree has exactly one child 891 12
C++ program for Bubble sort 812 15
C++ Program to Write to File 750 20
C++ program to merge Two binary search trees 1193 17
C++ program to binary Tree to binary search tree Conversion using std::Set 753 13
C++ Program to Find Sum of Natural Numbers Using Recursion 794 29
C++ program to find lowest Common Ancestor in a binary search tree 1071 19
C++ Program to Print Date and Time 825 11
C++ program to construct binary search tree from its given level order traversal 1026 29
C++ Program to List Files in Directory 1406 21
C++ Program to Swap Two Variables 767 15
C++ Program to Copy Files 1602 19
C++ Program to Calculate Grade of Student 3660 23
C++ Program to Get IP Address 3413 24
C++ Program to Find Largest of Two Number 923 20
C++ program to find K%u2019th largest element in binary search tree when tree modification is not allowed 778 22
C++ Program to Check Whether a String is Palindrome or Not 752 11

Comments