Given a number A. The task is to check whether A is positive, negative or zero.

Examples:
Input: A = 2 Output: 2 is positive Input: A = -554 Output: -554 is negative
In the below program, to find whether A is positive, negative or zero; first the number is taken as input from the user using scanf in
, and then A is checked for positive using
statement and
,
and
operators.
Below is the C program to find whether a number is positive, negative or zero.
#include <stdio.h> int main() { int A; printf("Enter the number A: "); scanf("%d", &A;); if (A > 0) printf("%d is positive.", A); else if (A < 0) printf("%d is negative.", A); else if (A == 0) printf("%d is zero.", A); return 0; } |
Output:
Enter the number A =: -54 -54 is negative.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Program to check if a number is Positive, Negative, Odd, Even, Zero
- Check whether product of integers from a to b is positive , negative or zero
- C program to count Positive and Negative numbers in an Array
- Python program to count positive and negative numbers in a list
- Check whether a number can be represented as sum of K distinct positive integers
- Find ratio of zeroes, positive numbers and negative numbers in the Array
- Program to check whether the given number is Buzz Number or not
- C Program to check Armstrong Number
- Program to check if N is a Star Number
- Program to check if N is a Hexagonal Number or not
- C Program to Check Whether a Number is Prime or not
- Program to check for Peterson number
- C++ Program to check Prime Number
- Lex program to check whether input number is odd or even
- Program to check if a number is divisible by sum of its digits
- Python program to check whether a number is Prime or not
- C Program to Check if all digits of a number divide it
- Program to check if a number belongs to a particular base or not
- Python program to print negative numbers in a list
- Python program to print all negative numbers in a range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

