#include <iostream> int main() { int N, M; int sum = 0; std::cout << "Enter value for N: "; std::cin >> N; std::cout << "Enter value for M: "; std::cin >> M; for(int i = N; i <= M; i++) { sum += i; } std::cout << "The sum of numbers from " << N << " to " << M << " is: " << sum << std::endl; return 0; }
int main() {
int N, M;
int sum = 0;
std::cout << "Enter value for N: ";
std::cin >> N;
std::cout << "Enter value for M: ";
std::cin >> M;
for(int i = N; i <= M; i++) {
sum += i;
}
std::cout << "The sum of numbers from " << N << " to " << M << " is: " << sum << std::endl;
return 0;
}