Program to Check Positive or Negative in C++ || Conditional Statement || C++
In this we are going to see how to make a Program in C++ to check a number is Negative or Positive.

The code given below can be used for TURBO C++ Compiler:-

#include<iostream.h>
#include<conio.h>

void main()
{
        clrscr();
	float a;
	cout<<"Enter you number"<<endl;
	cin>>a;
	if(a<0)
	{
		cout<<"The Entered number is negative \n";
	}
	else if(a>0)
	{
		cout<<"The entered number is positive \n";
	}
	getch();
}
    
    

The code given below can be used for g++/gcc Compiler:-

#include<iostream>
using namespace std;

int main()
{
	float a;
	cout<<"Enter you number"<<endl;
	cin>>a;
	if(a<0)
	{
		cout<<"The Entered number is negative \n";
	}
	else if(a>0)
	{
		cout<<"The entered number is positive \n";
	}
	return 0;
}

    
    

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post