#include // Query the user for two positive integers, // 'm' and 'n', and draw a rectangular grid of // asterisks with 'm' rows and 'n' columns. // // For example, if m = 5 and n = 7, the output // should be // // <--7--> // ^ ******* // | ******* // 5 ******* // | ******* // v ******* // // If the user enters a value for 'm' or 'n' // that is not positive, simply return 0. // Function declarations int main(); // Function definitions int main() { return 0; } // Hint: // // As the title suggests, this requires a loop // within another loop. // // for ( int row{ ... }; ...; ++row ) { // for ( int column{ ... }; ...; ++column ) { // // Do something... // } // // // Do something... // } // // The outer loop should execute once for each // row, while the inner loop should execute once // for each column. // // What should the initial values and conditions // of the two loops be? // We need to print 'm' rows. For each row, // we need to print 'n' asterisks. // // Thus, the outer loop could count from 1 // through 'm', while the inner loop could // count from 1 through 'n'. // // After the inner loop has printed all 'n' // asterisks for one row, what must be printed // before the next row begins? // Here is one solution: /* int main() { int m{}; std::cout << "Enter a positive integer 'm': "; std::cin >> m; int n{}; std::cout << "Enter another positive integer 'n': "; std::cin >> n; if ( (m <= 0) || (n <= 0) ) { return 0; } // The outer loop prints one row at a time. for ( int row{ 1 }; row <= m; ++row ) { // The inner loop prints the 'n' // asterisks in the current row. for ( int column{ 1 }; column <= n; ++column ) { std::cout << "*"; } // The current row is complete, so move // to the beginning of the next line. std::cout << std::endl; } return 0; } */