Header Ads

Header ADS

Solution of URI 1066::Even, Odd, Positive and Negative

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.




#include <stdio.h>

int main()
{
    int n[5],i;
    int cp=0,cn=0,co=0,ce=0;

        for (i=0;i<5;i++) {
        scanf("%d",&n[i]);
        }


    for(i=0;i<5;i++) {
            if(n[i]
%
2!=0) {
                co++;
            }
            if (n[i]%2==0) {
                ce++;
            }
            if(n[i]>0) {
                cp++;
            }
            if(n[i]<0) {
                cn++;
            }
        }

        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",ce,co,cp,cn);

        return 0;

}

No comments

Theme images by konradlew. Powered by Blogger.