This article shows that C++ Program to print Number Triangle. Like C++ program of alphabet triangle, we can write the C++ program to print the number triangle. The number triangle can be printed in different ways.
C++ Program to generate Fibonacci Triangle.
Let’s see the C++ program to print number triangle.
#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:
Enter the Range=4 1 121 12321 1234321
Enter the Range=5 1 121 12321 1234321 123454321
Note: If you interested lo learn C++ through web, You can click here
Conclusion:
Hi guys, I can hope that you can know that how to write a C++ Program to print Number Triangle. If you like this post as well as know something new so share this article in your social media accounts. If you have any doubt related to this post then you ask in comment section.