write a program to calculate 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
2
Answer:
Explanation:
#include<stdio.h>
int main()
{
int i, Minimum, Maximum, Even_Sum = 0, Odd_Sum = 0;
printf("\n Please Enter the Minimum, and Maximum Limit Values : \n");
scanf("%d %d", &Minimum, &Maximum);
for(i = Minimum; i <= Maximum; i++)
{
if ( i%2 == 0 )
{
Even_Sum = Even_Sum + i;
}
else
{
Odd_Sum = Odd_Sum + i;
}
}
printf("\n The Sum of Even Numbers betwen %d and %d = %d", Minimum, Maximum, Even_Sum);
printf("\n The Sum of Odd Numbers betwen %d and %d = %d", Minimum, Maximum, Odd_Sum);
return 0;
}
Similar questions