Wednesday, January 18, 2012

C Program on Pattern Printing


1234554321
1234---4321
123------321
12---------21
1------------1
12---------21
123------321
1234---4321
1234554321

C Programming codes to print the above pattern

#include<stdio.h>
void main()
{
int i,j,x,y=0,k,m,n;
m=5;
for (i=0;i<9;i++)
{
x=1;
for(j=0;j<m;j++)
printf("%d",x++);
for(k=0;k<y;k++)
printf(" ");
x--;
for(j=0;j<m;j++)
printf("%d",x--);
printf("\n");
if(i<9/2)
{
m--;
y=y+3;
}
else
{
m++;
y=y-3;
}
}
getch();
}

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner