C++ Program to print the sum of n odd numbers within range using do while

Program

#include <iostream>
using namespace std;
int main()
{
    int start_range, end_range;
    int sum = 0;
    cout << "Enter the starting range: ";
    cin >> start_range;
    cout << "Enter the ending range: ";
    cin >> end_range;
    cout << "Sum of all odd numbers in given range is :";
    int i = start_range;
    do
    {
        if (i % 2 != 0)
        {
            sum = sum + i;
        }
        i++;
    } while (i <= end_range);
    cout << sum;
    return 0;
}

Output

$ g++ sum-of-n-odd-numbers-within-range-using-do-while.cpp 
$ ./a.out
Enter the starting range: 2
Enter the ending range: 10
Sum of all odd numbers in given range is :24