C++ Program To Print Number Triangle - C++ Programming Tutorial
C++ Course / C++ Programs / C++ Program To Print Number Triangle

C++ Program To Print Number Triangle

BLUF: Mastering C++ Program To Print Number Triangle is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: C++ Program To Print Number Triangle

C++ is renowned for its efficiency. Learn how C++ Program To Print Number Triangle enables low-level control and high-performance computing in the tutorial below.

Similar to an alphabet triangle, we can develop a C++ program to display a numerical triangle. This numerical triangle can be generated in various formats.

Let's explore an example in C++ to display a triangle of numbers.

Example

Example

#include <iostream>

using namespace std;

int main()

{

int i,j,k,l,n;  

cout<<"Enter the Range=";  

cin>>n;  

for(i=1;i<=n;i++)  

{  

for(j=1;j<=n-i;j++)  

{  

cout<<" ";  

}  

for(k=1;k<=i;k++)  

{  

cout<<k;  

}  

for(l=i-1;l>=1;l--)  

{  

cout<<l;  

}  

cout<<"\n";  

}  

return 0;

}

Output:

Output

Enter the Range=5

     1

    121

   12321

  1234321

 123454321
Example

Enter the Range=6

      1

     121

    2321

   1234321 

  123454321

 12345654321

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience