Friday, 10 February 2017

sum of even and odd number in c

sum of  even and odd number in c 


#include<stdio.h>
int main()
{

int i,so=0,se=0,a[10];
printf("enter the number :=");
     for(i=0;i<9;i++)
     {
    scanf("%d",&a[i]);
     }
        for(i=0;i<9;i++)
        {
        if(a[i]%2==0)
            {
        se+=a[i];
        }
     else
        {
       so+=a[i];
        }
        }
     printf("\n sum of even number is %d",se);
     printf("\n sum of odd number is %d",so);
     return 0;
}


No comments:

Post a Comment