Friday, October 26, 2018

Uri 1066 solution in C | Even, Odd, Positive and Negative

/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/

#include<stdio.h>
main()
{
    int n,i,p=0,ne=0,e=0,o=0;
    for(i=0;i<5;i++)
    {
        scanf("%d",&n);
        if(n%2==0)
        {
            e++;
        }
        if(n%2!=0)
        {
            o++;
        }
        if(n>0)
        {
            p++;
        }
        if(n<0)
        {
            ne++;
        }

    }
    printf("%d valor(es) par(es)\n%d valor(es) impar(es)\n%d valor(es) positivo(s)\n%d valor(es) negativo(s)\n",e,o,p,ne);
    return 0;
}

 //Happy_Coding

No comments:

Post a Comment