fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. int rows;
  7. // Getting the number of rows.
  8. cout << "Enter the Number of rows - ";
  9. cin >> rows;
  10.  
  11. cout << "Triangle of " << rows << " using * -\n";
  12.  
  13. // Main logic to print triangle.
  14. for( int i = 0; i < rows; i++ ) {
  15. for( int j = 0; j <= i; j++ ){
  16. cout << "* ";
  17. }
  18. cout<<endl;
  19. }
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5296KB
stdin
6
stdout
Enter the Number of rows - Triangle of 6 using * -
*  
*  *  
*  *  *  
*  *  *  *  
*  *  *  *  *  
*  *  *  *  *  *