Wednesday, 30 July 2014

Program to print pattern.

//Program to print pattern.

#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
  for(int i=1;i<=5;i++)
{
  cout<<"\n";
  for(int j=4;j>=i;j--)
  cout<<"  ";
  for(int k=1;k<=i;k++)
  cout<<k<<" " ;
  for(int l=k-2;l>=1;l--)
  cout<<l<<" ";
}
  getch();
}

Output:


No comments:

Post a Comment