write a program to enter 10 numbers from user and display sum of all even numbers.
Answers
Answered by
3
Answer:
Coal is a combustible black or brownish-black sedimentary rock, formed as rock strata called ... The largest consumer and importer of coal is China.
Explanation:
Answered by
1
Explanation:
include <stdio.h>
void main()
{
int i, num, odd_sum = 0, even_sum = 0;
printf("Enter the value of num\n");
scanf("%d", &num);
for (i = 1; i <= num; i++)
{
if (i % 2 == 0)
even_sum = even_sum + i;
else
odd_sum = odd_sum + i;
}
printf("Sum of all odd numbers = %d\n", odd_sum);
printf("Sum of all even numbers = %d\n", even_sum);
}
Similar questions