Thursday, December 10, 2009

WAP to generate the peramid pattern

Write a program to generate the following pattern:

Output:-

1
121
12321
1234321
123454321

Solution:-

#include
#include

void main()
{
int i,j;
for (i=1;i<=5;i++) { for(j=4;j>=i;j--)
{
printf(" ");
}

for(j=1;j<=i;j++) { printf("%d",j); } printf("\n"); } getch(); }

No comments:

Post a Comment

Search This Blog