C Program to Check a number is Positive or Negative

This c program first prompts the user to enter a number. Then, it uses an if-else statement to check if the number is greater than zero, less than zero, or equal to zero. If the number is greater than zero, the program prints a message saying that the number is positive. If the number is less than zero, the program prints a message saying that the number is negative. If the number is equal to zero, the program prints a message saying that the number is zero.

Program :

#include<stdio.h>
#include<conio.h>
main()
{
int a;
printf(“Enter the number : “);
scanf(“%d”,&a);
if(a>0)
{
printf(“%d is Positive Number.”,a);
}
else
{
printf(“%d is Negative Number.”,a);
}
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights