#include <stdio.h>
int main() {
int a, b, sum, i;
printf("Enter a: ");
scanf("%d", &a);
printf("Enter b: ");
scanf("%d", &b);
sum = 0;
for (i=a; i<=b; i++) {
if (i%2 == 1) {
sum += i;
}
}
printf("The sum of odd numbers between %d and %d is %d.\n",
a, b, sum);
return 0;
}
Comments
Leave a comment