Saturday 27 December 2014

C Program to check whether a number is Positive or Negative number


This is a simple basic program which checks whether the number is positive or negative.

PROGRAM :

#include <stdio.h>
#include <stdlib.h>
int main()
{
    float a;
    printf("Enter any number :\n");
    scanf("%f",&a);

    if( a == 0)
        printf("%f is neither positive nor negative",a);
    else if( a > 0)
        printf("%f is a Positive number",a);
    else
        printf("%f is a Negative number",a);

    return 0;
}
OUTPUT :

C - Positive or Negative number