Sum Of Even And Odd Element Of Array - C Program

Sum Of Even And Odd Element Of Array

#include <stdio.h>
int main()
{
 int num[10],size=10,i,even=0,odd=0;
 
 printf("enter 10 elements of array : ");
 for(i=0;i<size;i++) 
    scanf("%d",&num[i]);
 for(i=0;i<size;i++)
  {
      if(num[i]%2==0)
        	even=even+num[i];
      else
	        odd=odd+num[i];
  }
       printf("\nsum of odd number in the array are :%d ",odd);
       printf("\nsum of even numbers in the array are :%d ",even);
   return 0;
}

Output - Sum Of Even And Odd Element Of Array

Enter 10 elements of array : 10 20 30 40 50 60 70 22 33 44                                                               
                                                                                                                      
sum of odd number in the array are :33                                                                                
sum of even numbers in the array are :346 
Compile and Run Online