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 integers -\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 << i + 1 << " ";
  17. }
  18. cout<<endl;
  19. }
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5300KB
stdin
6
stdout
Enter the Number of rows - Triangle of 6 using integers -
1 
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5 
6 6 6 6 6 6