PROGRAM TO PRINT A PATTERN – 1

/*PROGRAM TO PRINT A PATTERN*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,temp=0,k;
clrscr();
printf(“Press any key to display the pattern\n”);
getch();
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
temp++;
printf(“%d “,temp);
}
if(temp>1)
{
for(k=j-2;k>=1;k–)
{
temp–;
printf(“%d “,temp);
}
}
printf(“\n”);
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *