Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 6.22 Triangle of Asterisks
- Deitel & Deitel C++ How to Program, 10th ed (Indian subcontinent adaptation)
- Visual Studio Community 2019
- */
- #include < iostream>
- using namespace std;
- void triangle(int height) {
- for (int row = 1; row <= height; row++) {
- for (int col = 1; col <= row; col++) {
- cout << "*";
- }
- cout << endl;
- }
- }
- int main()
- {
- int height{ 0 };
- while (true) {
- cout << "Enter height of triangle ( 0 to exit ): ";
- cin >> height;
- if (height == 0) break;
- else triangle(height);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment