Classification of Integers

This C program reads a number N and then reads N integers, classifying each integer as 'EVEN NEGATIVE', 'EVEN POSITIVE', 'ODD NEGATIVE', 'ODD POSITIVE', or 'NULL'. It provides a structured approach to determine the properties of numbers inputted by the user.
 avatar
asikafridi
c_cpp
9 days ago
630 B
10
Indexable
Never
#include<stdio.h>
int main() 
{
    long long int N, X,i;
    scanf("%lld",&N);
    for(i = 0; i <= N; i++)
    {
        scanf("%lld", &X);
        if((X % 2 == 0) && (X < 0))
        {
            printf("EVEN NEGATIVE\n");
        }
        else if((X % 2 == 0) && (X > 0))
        {
            printf("EVEN POSITIVE\n");
        }
        else if((X % 2 != 0) && (X > 0))
        {
            printf("ODD POSITIVE\n");
        }
        else if((X % 2 != 0) && (X < 0))
        {
            printf("ODD NEGATIVE\n");
        }
        else if(X == 0)
        {
            printf("NULL\n");
        }
    }

    return 0;
}
Leave a Comment