#include /******************************** * Query the user for two * integers, and then calculate * and print the sum of all the * integers from the smaller to * the larger, inclusive. ********************************/ // Function declarations int main(); // Function definitions int main() { int m{}; std::cout << "Enter a first integer: "; std::cin >> m; int n{}; std::cout << "Enter a second integer: "; std::cin >> n; std::cout << "The sum is 0" << std::endl; return 0; } // Hint: First ensure that the smaller value // is stored in 'm' and the larger value in // 'n'. Then use a for loop and an accumulator // to calculate the sum. /* This is one solution: int main() { int m{}; std::cout << "Enter a first integer: "; std::cin >> m; int n{}; std::cout << "Enter a second integer: "; std::cin >> n; if ( m > n ) { // Swap the two values. int tmp{ m }; m = n; n = tmp; } int sum{ 0 }; for ( int k{ m }; k <= n; ++k ) { sum += k; } std::cout << "The sum is " << sum << std::endl; return 0; } */