URI Online Judge | 1065
Even Between five Numbers
Make a program that reads five integer values. Count how many of these values are even and print this information like the 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 even numbers were typed.
Input Sample | Output Sample |
7 -5 6 -4 12 | 3 valores pares |
Solution:
#include <stdio.h>
int main()
{
int a, i;
int tmp = 0;
for (i = 0; i < 5; ++i)
{
scanf("%d", &a);
if(a < 0){
a = -a;
}
if(a % 2 == 0){
tmp++;
}
}
printf("%d valores pares\n", tmp);
return 0;
}
|
Post a Comment
0Comments