#include<iostream>
using namespace std;
int main()
{
int i, j, n=1, cnt;
cout<<"\n Enter Number of Rows : ";
cin>>cnt;
cout<<"\n";
for(i=0; i<cnt; i++)
{
for(j=0; j<=i; j++)
{
cout<<n<<" ";
n++;
}
cout<<"\n";
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int i, j, num=1, cnt;
cout<<"\n Enter Number of Rows : ";
cin>>cnt;
cout<<"\n";
for(i=0; i<cnt; i++)
{
num=1;
for(j=0; j<=i; j++)
{
cout<<num<<" ";
num++;
}
cout<<"\n";
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int i, j, num=1, cnt;
cout<<"\n Enter Number of Rows : ";
cin>>cnt;
cout<<"\n";
for(i=0; i<cnt; i++)
{
for(j=cnt; j>i; j--)
{
cout<<num<<" ";
num++;
}
cout<<"\n";
num=1;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int i, j, k, num=1, decr=8, count=0, temp, rows;
cout<<"\n Enter Number of Rows : ";
cin>>rows;
for(i=0; i<rows; i++)
{
for(k=0; k<decr; k++) // This loop prints the spaces
{
cout<<" ";
}
for(j=0; j<i; j++) // This loop gives the required value to variable num
{
count++;
}
num = count;
temp = num;
for(j=0; j<i; j++) // This loop prints the numbers
{
cout<<num--<<" ";
}
cout<<"\n";
num = temp;
decr=decr-2;
}
return 0;
}