Saturday, April 11, 2009

PROG:- Sum of Odd And Even No.s

#include
#include
void main()
{
int a[20],n,m,sum=0,sum2=0;
clrscr();
printf("enter the total no. to be inserted");
scanf("%d",&m);
clrscr();
for(n=1;n<=m;n++);
{
printf("enter ur value");
scanf("%d",&a[n]);
if (a[n]%2==0)
{
sum=sum+a[n];
}
else
{
sum2=sum2+a[n];
}
}
printf("sum of even no.s is %d",sum);
printf("\n sum of odd no.s is %d",sum2);
getch();
}

No comments:

Post a Comment

Search This Blog