Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scratchyourbrain/16e8d898db180e3f4b0d to your computer and use it in GitHub Desktop.
Save scratchyourbrain/16e8d898db180e3f4b0d to your computer and use it in GitHub Desktop.
C Program to Check Whether a Number is Positive or Negative or Zero.
#include <stdio.h>
int main()
{
float num;
printf("Enter a number: ");
scanf("%f",&num);
if (num<0) /* Checking whether num is less than 0*/
printf("%.2f is negative.",num);
else if (num>0) /* Checking whether num is greater than zero*/
printf("%.2f is positive.",num);
else
printf("You entered zero.");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment