WAP to add even and odd numbers from 10to 20
Store them and display their Results in two separate
arrays.
Answers
Answered by
0
Program is given below.
Explanation:
#include <stdio.h>
int main() {
int even[10],odd[10],
number[20]={10,11,12,13,14,15,16,17,18,19,20},even_sum=0,odd_sum=0,i;
for(i=0;i<11;i++) //From 10 to 20 there are 11 numbers.
{
if(number[i]%2==0)
{
even[i]=number[i];
even_sum=even_sum+even[i];
}
else
{
odd[i]=number[i];
odd_sum=odd_sum+odd[i];
}
}
printf("Even numbers sum is = %d\nOdd numbers sum is = %d",even_sum,odd_sum);
return 0;
}
Refer the attached image for the output.
Attachments:
Similar questions