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 -\n ";
  9. cin>>rows;
  10.  
  11. cout<<"pyramid using Numbers :\n";
  12.  
  13. // Main logic to print half pyramid.
  14. for( int i = 0; i < rows; i++ ) {
  15. for( int j = 0; j <= i; j++ ){
  16. cout << i+1<<" ";
  17. }
  18. cout<<endl;
  19. }
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5276KB
stdin
5
stdout
Enter the Number of rows -
 pyramid using Numbers :
1 
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5