Sunday, March 17, 2013

Count Even Or Odd

#include<iostream>
using namespace std;
int main()
{
    int arr[]={2,5,7,8,4};
    int even=0,odd=0;
    int a,b;
    for(int i=0;i<=arr[i];++i)
    {
        if(arr[i]%2==0)
        {
            even+=1;
            a=even;
        }
        else
        {
            odd+=1;
            b=odd;
        }
    }
    cout<<a<<"    "<<b;
    return 0;
}

0 comments:

Post a Comment