Positive or Negative number in C++ - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 12, 2020

Positive or Negative number in C++


C++ PROGRAM TO CHECK WHETHER THE NUMBER IS A POSITIVE OR NEGATIVE NUMBER


Sample Test Case    :    Enter a Number : 5

Sample Test Case    :    5 is a Positive Number


CODE


#include<stdio.h>
int main()
{
    int num;
    cout<<"Enter a Number :";
    cin>>num;
    if(num==0)
    {
        cout<<"Zero";
    }
    else if(num>0)
    {
        cout<<num<<"is a Positive Number";
    }
    else if(num<0)
    {
        cout<<num<<"is a Negative Number";
    }
    return 0;
}

No comments:

Post a Comment