fork download
  1. // Print Full Pyramid Pattern of Stars
  2.  
  3.  
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6.  
  7. int main(){
  8.  
  9. int rows;
  10. // Getting the number of rows.
  11. cout << "Enter the Number of rows - ";
  12. cin >> rows;
  13.  
  14. cout << "Full Pyramid of " << rows << " using * -\n";
  15.  
  16. // Main logic to print full pyramid.
  17. for( int i = 0; i < rows; i++ ) {
  18. // Print spaces.
  19. int spaces = rows - i;
  20.  
  21. for( int j = 0; j < spaces; j++){
  22. cout <<" ";
  23. }
  24.  
  25. // Print stars.
  26. for( int j = 0; j < 2 * i - 1; j++){
  27. cout <<"* ";
  28. }
  29.  
  30. cout << endl;
  31.  
  32. }
  33.  
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0.01s 5280KB
stdin
6
stdout
Enter the Number of rows - Full Pyramid of 6 using * -
            
          * 
        * * * 
      * * * * * 
    * * * * * * * 
  * * * * * * * * *