Answers for "sample program that output triangle of numbers in c++"

C++
0

Write a 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;  
}
Posted by: Guest on May-24-2021

Code answers related to "sample program that output triangle of numbers in c++"

Browse Popular Code Answers by Language