#include /**************************************************************** * Query the user for two integers, and print all the * integers from the first up to or down to and including the * second. ****************************************************************/ // 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; for ( ; ; ) { std::cout << 0 << " "; } std::cout << std::endl; return 0; } // Hint: You will probably need two separate // for loops and a conditional statement to // determine which one should execute: one loop // counts up, while the other counts down. /* Both of these solutions work: 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 ) { for ( int k{ m }; k <= n; ++k ) { std::cout << k << " "; } } else { for ( int k{ m }; k >= n; --k ) { std::cout << k << " "; } } std::cout << std::endl; return 0; } // This solution uses a single for loop. Determine // why choosing the appropriate value of 'step' // ensures that the loop always reaches 'n'. int main() { int m{}; std::cout << "Enter a first integer: "; std::cin >> m; int n{}; std::cout << "Enter a second integer: "; std::cin >> n; int step{}; if ( m <= n ) { step = 1; } else { step = -1; } for ( int k{ m }; k != n; k += step ) { std::cout << k << " "; } std::cout << n << std::endl; return 0; } */