write a program to calculate and display the sum of all odd numbers and even numbers between a range of numbers from m to n (both inclusive) where m<n . input m and n
Answers
Answered by
4
Answer:
CLICK THE BRilliant
Explanation:
The program output is also shown below.
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;
odd_sum = odd_sum + i;
printf("Sum of all odd numbers = %d\n", odd_sum);
Similar questions
Math,
4 months ago
English,
4 months ago
Business Studies,
8 months ago
Environmental Sciences,
8 months ago
Math,
11 months ago
Math,
11 months ago