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. Required fields are marked *

Shopping Basket
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare
Verified by MonsterInsights