#include<stdio.h>
#include<conio.h>
void main()
{
int i, limit, no[97], sum=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 == 1)
{
sum = sum + no[i];
}
}
printf("\n\nSum of Odd numbers = %d", sum);
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 of Odd numbers = 9
*/
No comments:
Post a Comment