2

Click here to load reader

Program to Print the Pattern1

Embed Size (px)

Citation preview

Page 1: Program to Print the Pattern1

www.w3professors.com Gursharan Singh Tatla Page No. 1

/*

Program to Print the Following Output:

1

121

12321

1234321

123454321

12345654321

1234567654321

123456787654321

12345678987654321

*/

#include <stdio.h>

main()

{

int i, j, k, space, n=9;

for (i=1; i<=n; i++)

{

for (j=1; j<=n-i; j++)

putchar(' ');

for (j=1,k=2*i-1; j<=2*i-1; j++,k--)

{

Page 2: Program to Print the Pattern1

www.eazynotes.com Gursharan Singh Tatla Page No. 2

if (j <= k)

printf("%d", j);

else

printf("%d", k);

}

putchar('\n');

}

getch();

}