C Program to print the sum of n odd numbers within range using for

Program

#include <stdio.h>
void main()
{
    int i;
    int start_range, end_range;
    int sum = 0;
    printf("Enter the starting range:\t");
    scanf("%d", &start_range);
    printf("Enter the ending range:\t");
    scanf("%d", &end_range);
    printf("Sum of all odd numbers in the given range is: ");
    for (i = start_range; i <= end_range; i++)
        if (i % 2 != 0)
            sum = sum + i;
    printf("%d",sum);
}

Output

$ gcc sum-of-n-odd-numbers-within-range-using-for.c 
$ ./a.out
Enter the starting range:       5
Enter the ending range: 20
Sum of all odd numbers in the given range is: 96