Question #49737

I want to make a program to display following pattern
3
2 3 2
2 3 4 3 2
2 3 4 5 4 3 2

Expert's answer

#include<stream.h>
#include<conio.h>

int main()
{
int n=5,i,j;
cout<<"3\n";
for(j=3;j<=n;j++)
{
for(i=2;i<j;i++)
cout<<i<<" ";
for(i=j;i>=2;i--)
cout<<i<<" ";
cout<<endl;
}
getch();
return 1;

}

LATEST TUTORIALS
APPROVED BY CLIENTS