WAP to check whether element of array is odd or even and also find their sum and product.
C Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int num[5],a,sum=0,mul=1;
clrscr();
for(a=0;a<5;a++)
{
printf("\nenter no[%d]:",a+1);
scanf("%d",&num[a]);
}
for(a=0;a<5;a++)
{
if(num[a]%2==0)
{
printf("\neven no:%d",num[a]);
sum=sum+num[a];
}
else
{
printf("\nodd no:%d",num[a]);
mul=mul*num[a];
}
}
printf("\nsum of even no:%d",sum);
printf("\nmulty of odd no:%d",mul);
getch();
}


No comments