Advertisement
payjack

trianglenestedloop

Nov 1st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. //nested loops
  2. //Mrs. Kubik
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int getInput ()
  7. {
  8.     int x = 0;
  9.     cout << "How tall would you like the triangle to be?" << endl;
  10.     cin >> x;
  11.     return x;
  12. }
  13. int main()
  14. {
  15.     int x = getInput();
  16.     for (int i=1; i<=x; i++)
  17.     {
  18.         cout<<"*"<<endl;
  19.  
  20.     for (int j=1; j<=i; j++)
  21.     {
  22.         cout<<"*"<<endl;
  23.     }
  24.     }
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement