
Even, Odd, Positive and Negative
Adapted by Neilor Tonin, URI Brazil
Make a program that reads five integer values. Count how many of these values are even, odd, positive, and negative. 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 of these values are even, odd, positive, and negative.
Input Sample | Output Sample |
-5 |
3 valor(es) par(es) |
URI - BEECROWD Online Judge 1066 Solve in C :
//Solved by Intesar#include <stdio.h>
int main() {
int x,i,e=0,o=0,p=0,n=0;
for(i=0;i<5;i++) { scanf("%d",&x); if(x%2==0) e++; else o++; if(x>0) p++; else if(x<0) n++; }
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); return 0;}
0 Comments