Header Ads

Header ADS

Solution of URI 1074::Even or Odd

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.




#include <stdio.h>

int main()
{
    int N;
    long int X;

    scanf(
"
%d"
,&N);

    while(N--) {
        scanf("%ld",&X);
        if(X==0) {
            printf("NULL\n");
        }
        else if (X%2==0) {
            if (X>0) {
                printf("EVEN POSITIVE\n");
            }
            else {
                printf("EVEN NEGATIVE\n");
            }
        }

        else if (X%2 !=0) {
            if (X>0) {
                printf("ODD POSITIVE\n");
            }
            else {
                printf("ODD NEGATIVE\n");
            }
        }
    }

    return 0;
}

No comments

Theme images by konradlew. Powered by Blogger.