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