[URI Online Judge] – 1066 – Even, Odd, Positive and Negative

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 ​​are even, odd, positive and negative.

Sample Input Sample Output
-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 <cstdio>
int main(){
 int c = 5, x, p = 0, n = 0, e = 0, o = 0;
 while(c--){
 scanf("%d", &x);
 if (x < 0)
 n++;
 else if (x > 0)
 p++;
 if (x % 2 == 0)
 e++;
 else
 o++;
 }
 printf("%d valor(es) par(es)\n", e);
 printf("%d valor(es) impar(es)\n", o);
 printf("%d valor(es) positivo(s)\n", p);
 printf("%d valor(es) negativo(s)\n", n);
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s