Table of Contents

**Write a program to find the positive and negative number?**

**Logic:**

**Number is positive** if number > 0

**For example:** 4 > 0 so 4 is a positive number

**Number is negative** if number < 0

**For example:** -4 < 0 so -4 is a negative number

**Program:**

#include<iostream> using namespace std; int main() { int number; cout<<"Enter any number"<<endl; cin>>number; if(number<0) { cout<<"Number is negative"<<endl; } else { cout<<"Number is positive"<<endl; } }

**Program with Comments:**

#include<iostream> //Adding the header file iostream using namespace std; //Adding the namespace int main() //Starting of integer type main function { //Starting of main function int number; //eclaration of integer type variable named as number. Variable number can have any value. cout<<"Enter any number"<<endl; //Display message. cin>>number; //User input the integer value and value is stored in variable number. if(number<0) //Value in variable number is checked by if condition. If the value of a number is less than 0, then the number is negative and control moves to the statement 9.But if the value of a number is greater than 0, then the number is positive and control moves to the statement 12. { //start of if body cout<<"Number is negative"<<endl; //Display the message that number is negative. } //ending of if else Control arrives at statement 12 if the condition is false at statement 8. { cout<<"Number is positive"<<endl; //Display message that number is positive. } //Ending of else. } //Ending of main function.

**Output:**

Sir this program helps us to identify that the number is positive or negative.If we enter a number and it is greater than zero then the number will be positive similarly if we enter a number and it is less then zero then the number will be negative

This program is to identify whether the number is positive or negative. According to this program, we take a number and add a condition to check if the number is positive or negative. If the number is less then zero then it’s negative and if it’s greater then 0 then it’s positive

In this program, we ask a user to type any number and we tell them rather the number is positive or negative.we use if & else condition to identify that number is positive or negative.if the condition is true it prints(if) statement rather it prints else statement

Truly thankful for putting comments to each line. It helped a lot understanding whether the specific functions should be called, how a variable is declared, how to take input from the user and store in a variable and how to Print the nature of inputted value after checking if it is positive or negative through if statement.

Never seen such a fantastic tutorial before. This program tells us if I put the number if greater then zero they show a number is a positive number or if less than zero they show a negative number, for example, I put -666 the program shows the negative number if I put the 866 number they show a positive number

Feeling thankful while reading this article. According to this program, firstly we take a number from the user. Secondly, we use if condition to find out whether the number is negative or positive. If the number is greater than zero the number is positive or the number is less than zero the number is negative. Please upload more programs.

In this program we have to find the positive & negative number using if & else conditions if the number is greater than 0 print that the number is positive if the number is less than 0 than print that the number is negative

In this program, we find the positive and negative numbers by using if condition .first of all we declare integer type variable (number).use count and display a message (enter any number).value is check by if condition.

According to the program, Enter no.from the user. If the condition Is true, then print that the NO is Negative and If the condition is false, then Print that NO is Postive.

Nice Post. This is a program to identify rather the given number is a positive or negative number.

In this program, we have taken a number and then we added a condition that if our number is less then zero then it will be a negative number otherwise it will be a positive number.