Feb 7, 2022

Find if the number is positive or Negative (C Language)

finding the sign (+/-) of number using condition statements

 #include <stdio.h>
int main()
{
    // Program to check if number is positive or negative
    int a;
    printf("Enter the Number (to check +ve/-ve ) : ");
    scanf("%d" , &a);
    if (a > 0)
    {
        printf("Result : %d Number is positve." , a);
    }
    else if (a == 0)
    {
        printf("Result : %d Number is zero(neither +ve or -ve)." , a);
    }
    else
    {
        printf("Result : %d Number is Negative." , a);
    }

    return 0;
}

No comments:

Post a Comment

Comparing two files in C language.

Operations on More than one File.    # include < stdio.h > # include < stdlib.h > # include < string.h > int main ( int ...