1074 Even or Odd

SemiColon
By -
0
URI Online Judge | 1074

Even or Odd

Read an integer value N. After, read these N values and print a message for each value saying if this value is oddevenpositive or negative. In case of zero (0), although the correct description would be "EVEN NULL", because by definition zero is even, your program must print only "NULL", without quotes.

Input

The first line of input is an integer (< 10000), that indicates the total number of test cases. Each case is a integer number (-107 < X <107)..

Output

For each test case, print a corresponding message, according to the below example. All messages must be printed in uppercase letters and always will have one space between two words in the same line.
Input SampleOutput Sample
4
-5
0
3
-4
ODD NEGATIVE
NULL
ODD POSITIVE
EVEN NEGATIVE

 Solution:
#include <stdio.h>
int main( ){

 int N, i, x;
 scanf("%d", &N);
 for( i = 1; i <= N; i++){
  scanf("%d", &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 > 0){
    printf("ODD POSITIVE\n");
   }else{
    printf("ODD NEGATIVE\n");
   }
  }

 }
return 0;
}


Tags:

Post a Comment

0Comments

Post a Comment (0)