Programmer

Wednesday, 18 April 2018

Pattern to print 1 232 34543...



#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int i,j,n,k,a=0,l;
clrscr();
cout<<"Enter Number :";
cin>>n;
for(i=1;i<=n;i++)
{
a=i+(i-1);
for(j=1;j<=n-i;j++)
{
cout<<"  ";
}
for(j=i;j<=a;j++)
{
cout<<setw(2)<<j;
}
for(l=a-1;l>=i;l--)
{
cout<<setw(2)<<l;
}
cout<<endl;
}
getch();
}

No comments:

Post a Comment

Program To Print Particular Line From File.

#include<fstream.h> #include<conio.h> #include<stdlib.h> void main() { ifstream fin; int count=0,num,l=1; char ...