ADVANCED & VERY INTERESTING PATTERN IN C++ (TRY IT OUT ITS VERY LOGICAL)



#include<iostream.h>
#include<conio.h>
#include<iomanip.h>

void main()
{
int n,i,count=0,temp=1,sum=1;
clrscr();
cout<<"Enter Number :";
cin>>n;

for(i=1;i<=n;i++)
{
count=sum;
for(int j=1;j<n*2;j++)
{
if(i-j>=1||i+j>=n*2+1)
{
cout<<"    ";
}
else
{
if(j<=n)
{
cout<<setw(4)<<count;
count+=j;
}
else
{
cout<<setw(4)<<count;
count+=((n*2)-j);
}
}
}
temp++;
sum+=temp;
cout<<endl;
}
getch();
}

No comments

Post your comments

Powered by Blogger.