get sum in range

#include <iostream>

int getSumInRange(int start, int end) {
    int sum = 0;
    for (int i = start; i <= end; ++i) {
        sum += i;
    }
    return sum;
}

int main() {
    int start, end;

    // Input the range
    std::cout << "Enter the start of the range: ";
    std::cin >> start;

    std::cout << "Enter the end of the range: ";
    std::cin >> end;

    // Calculate and display the sum
    int result = getSumInRange(start, end);
    std::cout << "Sum of numbers in the range [" << start << ", " << end << "] is: " << result;

    return 0;
}