#include // Query the user for one positive integer 'm' // and draw a triangle of asterisks with 'm' rows. // // The first row contains one asterisk, the second // row contains two asterisks, and so on, with the // final row containing 'm' asterisks. // // For example, if m = 5, the output should be // // ^ * // | ** // 5 *** // | **** // v ***** // // If the user enters a value for 'm' that is not // positive, simply return 0. // Function declarations int main(); // Function definitions int main() { return 0; } // Hint: // // Like the previous exercise, this requires a // loop within another loop. We must print 'm' // rows, so the outer loop will look like: // // for ( int row{ 1 }; row <= m; ++row ) { // // // Print the appropriate number of // // asterisks for this row. // // std::cout << std::endl; // } // // Unlike the previous exercise, however, the // number of asterisks printed in each row is // not constant: // // row 1: 1 asterisk // row 2: 2 asterisks // row 3: 3 asterisks // ... // row m: m asterisks // // How can the value of 'row' be used to control // the inner loop? // The value of 'row' determines how many // asterisks must be printed on that row. // // Thus, the inner loop should count from 1 // through the current value of 'row'. // // Notice the difference from the previous // exercise: the upper bound of the inner loop // changes each time the outer loop executes. // Here is one solution: /* int main() { int m{}; std::cout << "Enter a positive integer 'm': "; std::cin >> m; if ( m <= 0 ) { return 0; } for ( int row{ 1 }; row <= m; ++row ) { for ( int column{ 1 }; column <= row; ++column ) { std::cout << "*"; } std::cout << std::endl; } return 0; } */