#include<stdio.h>
#include<conio.h>
void main()
{
int i, limit, no[97], sume=0, sumo=0;
clrscr();
printf("How many numbers you want to enter? ");
scanf("%d", &limit);
printf("\nEnter %d numbers one by one\n", limit);
for(i=0; i<limit; i++)
{
printf("Enter number %d: ", i+1);
scanf("%d", &no[i]);
}
for(i=0; i<limit; i++)
{
if(no[i]%2 == 0)
{
sume = sume + no[i];
}
else
{
sumo += no[i];
}
}
printf("\n\nSum Odd = %d\nSum Even = %d", sumo, sume);
getch();
}
/*
How many numbers you want to enter? 5
Enter 5 numbers one by one
Enter number 1: 1
Enter number 2: 2
Enter number 3: 3
Enter number 4: 4
Enter number 5: 5
Sum Odd = 9
Sum Even = 6
*/
No comments:
Post a Comment