Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Monday, 14 November 2016

URI-1074

URI Online Judge | 1074

Even or Odd

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
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 t,n,i;
    scanf("%d",&t);
    for(i=1;i<=t;i++){
        scanf("%d",&n);
        if(n%2!=0){
            if(n>0){
                printf("ODD POSITIVE\n");
            }
            else if(n<0){
                printf("ODD NEGATIVE\n");
            }
        }
        if(n%2==0){
            if(n>0){
                printf("EVEN POSITIVE\n");
            }
            else if(n<0){
                printf("EVEN NEGATIVE\n");
            }
        }
        if(n==0){
            printf("NULL\n");
        }
    }
    return 0;
}

No comments:

Post a Comment