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-1066

URI Online Judge | 1066

Even, Odd, Positive and Negative

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
Make a program that reads five integer values. Count how many   of these values are even, odd, positive and negative. Print these information like following example.

Input

The input will be 5 integer values.

Output

Print a message like the following example with all letters in lowercase, indicating how many of these values ​​areeven, odd, positive and negative.
Input SampleOutput Sample
-5
0
-3
-4
12
3 valor(es) par(es)
2 valor(es) impar(es)
1 valor(es) positivo(s)
3 valor(es) negativo(s)

Solution....

#include<stdio.h>
int main()
{
    int even=0,odd=0,positive=0,negetive=0,n=0,a;
    while(n!=5){
        scanf("%d",&a);
        if(a%2==0){
            even++;
        }
        if(a%2!=0){
            odd++;
        }
        if(a>0){
            positive++;
        }
        if(a<0){
            negetive++;
        }
        n++;
    }
    printf("%d valor(es) par(es)\n",even);
    printf("%d valor(es) impar(es)\n",odd);
    printf("%d valor(es) positivo(s)\n",positive);
    printf("%d valor(es) negativo(s)\n",negetive);
    return 0;
}

No comments:

Post a Comment