Sum of all odd integers

Take n integers from user in an array . Now find the sum of all odd integers and sum of all even integers .
‪#‎include‬<stdio.h>
#include<conio.h>
void main()
{int n , i , e , o , a[100] ;
printf("\n enter how many number you want = ");
scanf("%d",&n);
printf("\n enter numbers -\n");
for(i=0;i<n;i )
{
scanf("%d",&a[i]);
}
e=0;
o=0;
for(i=0;i<n;i )
{
if(a[i]%2==0)
{
e=e a[i];
}
else
{
o=o a[i];
}
}
printf("\n\n sum of odd numbers=%d",o);
printf("\n sum of even numbers=%d",e);
getch();
return;
}
‪#‎lets‬ try this .

Post a Comment

0 Comments