Write a program to find the sum of even and odd numbers in an array. Input Format: Input consists of n+1 integers. The first integer corresponds to n , the size of the array. The next n integers correspond to the elements in the array. Assume that the maximum value of n is 15. Output Format: Refer sample output for details. Test Case 1 Input (stdin) 5 2 3 6 8 3 Expected Output even=16 odd=6 Test Case 2 Input (stdin) 7 1 2 3 4 5 6 7 Expected Output even=12 odd=16
#include <stdio.h>
int main()
{
int a,b,i,even,odd;
scanf("%d",&a);
for(i=0;i<a;i++)
{
scanf("%d",&b);
if(b%2==0)
{
even=even+b;
}
else
{
odd=odd+b;
}
}
printf("even=%d",even);
printf("\nodd=%d",odd);
return 0;
}