Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to find if a number is possitive or negative in c++

#include<iostream>

using namespace std;

int main ()

{

    int num;

    cout << "Enter the number to be checked : ";

    cin >> num;

    if (num >= 0)

        cout << num << " is a positive number.";

    else 

        cout << num << " is a negative number.";

    return 0;

}
Comment

check if number is positive or negative in cpp

// positive negative or zero

#include <iostream>
using namespace std;

int main()
{
    int num;

    cout<< "Enter the number: ";
    cin >> num;

    if(num>0)
        cout<< "Positive";
    else if (num<0)
        cout<< "Negative";
    else
        cout<< "Zero";

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ map access 
Cpp :: c+ 
Cpp :: std::hash 
Cpp :: Pawri Meme codechef solution in c++ 
Cpp :: how to add 2 objects using operator overloading in c++ 
Cpp :: iff cpp 
Cpp :: Use command line arguments to create file c++ 
Cpp :: how to test if char in = to another in c++ 
Cpp :: ue4 array copy c++ 
Cpp :: no argument but return value in c++ 
Cpp :: how to delete repeated element in stack c++ 
Cpp :: how the theam are store in database 
Cpp :: simplest code for stack implementation in c++ 
Cpp :: set app icon qt 
Cpp :: c++ language 
Cpp :: ue4 log 
Cpp :: temporary variable ex c++ 
Cpp :: csv 
Cpp :: qt widget list set selected 
Cpp :: Lapindromes codechef solution in c++ 
Cpp :: pointeur cpp 
Cpp :: bullet physics directx 11 
Cpp :: c++ find string in string 
Cpp :: c++ set element at index 
Cpp :: stream in c++ 
Cpp :: c++ loop array 
Cpp :: no match for ‘operator=’ (operand types are ‘std::basic_ostream’ and ‘int’) 
C :: how to remove button decoration 
C :: classification report to excel 
C :: how to print helloq world in c 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =