Header Ads Widget

C++ program to check whether a number is negative, positive or zero

 

 C++ program to check whether a number is negative, positive or zero

Given a numbers , write a program to check that whether a number is negative, positive or zero .

Sample input

4

Sample output

Number is Positive number

C++ program to check whether a number is negative, positive or zero

The objective of the code is to check whether a number is negative, positive or zero .

Code(C++):-

#include <bits/stdc++.h>
using namespace std;
int main() {
    int a;
    cin>>a;
    if(a==0)
     cout<<"Number is zero";
else if(a>0)
     cout<<"Number is Positive number";
    else
     cout<<"Number is Negative number";
}

Output:-

4
Number is Positive number

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-