In this C program, we will learn about how to read a number and check whether number is positive, negative or zero. We will first take an integer as input from user using scanf function. Then we check whether input number is positive, negative or zero using if else ladder statement.
Required Knowledge
C program to check whether an integer is negative, positive or zero
#include <stdio.h> int main() { int number; printf("Enter a Number\n"); scanf("%d", &number); if(number > 0) { printf("%d is Positive Number", number); } else if (number < 0) { printf("%d is Negative Number", number); } else { printf("Input Number is Zero"); } return 0; }Output
Enter a Number 5 5 is Positive Number
Enter a Number -3 -3 is Negative Number
Enter a Number 0 Input Number is ZeroRelated Topics