Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

countoddevenDifference

#include <stdio.h>
int countOddEvenDifference(int n, int arr[])
{
    int odd = 0, even = 0;
    for(int i=0; i<n; i++)
    {
        if(arr[i]%2==0)
        {
            even = even+1;
        }
        else
        {
            odd = odd+1;
        }   
    }
    return odd - even;
}
int main()
{
    int n;
    scanf("%d",&n);
    int array[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d",&array[i]);
    }
    int result = countOddEvenDifference(n, array);
    printf("%d",result);
    return 0;
}
Source by prepinsta.com #
 
PREVIOUS NEXT
Tagged: #countoddevenDifference
ADD COMMENT
Topic
Name
9+5 =