URI - BEECROWD - BEE 1066 - Even,Odd,Positive and Negative Solution in C,C++,Python

 URI - BEECROWD - BEE 1066 - Even,Odd,Positive and Negative Solution in C,C++,Python |  URI - BEECROWD - BEE Online Judge Solution 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.

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)

URI - BEECROWD - BEE 1066 - Even,Odd,Positive and Negative Solution in C,C++,Python |  URI - BEECROWD - BEE Online Judge Solution 1066 - Even,Odd,Positive and Negative:

                                        Demonstration:

Even numbers are those numbers that can be divided into two equal groups or pairs and are exactly divisible by 2.
Any integer that cannot be divided exactly by 2 is an odd number.
even or odd


A number is positive if it is greater than zero.  A number is negative if it is less than zero.
Here we apply a range-based for loop which provides all the integers available in the input interval.
After this, checking the condition for even,odd,positive and negative numbers are applied and increment these variable. 
Finally, print the result.

N.B: Don't copy paste the code as same. Just try to understand it and try yourself.


   URI - BEECROWD - BEE Problem 1066 Solution in C :   

   URI - BEECROWD - BEE Online Judge 1066 Solve  in C :                              

#include <stdio.h>
 
int main() {
        int i,num,even=0,odd=0,positive=0,negative=0;
        for(i=1;i<=5;i++){
            scanf("%d",&num);
            if(num%2==0){
                even++;
            }
            if(num%2!=0){
                odd++;
            }
            if(0<num){
                positive++;
            }
            if(0>num){
                negative++;
            }
    
       } 
        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",negative);
        
    return 0;
}

0 Response to URI - BEECROWD - BEE 1066 - Even,Odd,Positive and Negative Solution in C,C++,Python

Post a Comment