Monday, June 18, 2012

To print the pattern


/* To print the pattern */

#include<stdio.h>

#include<conio.h>

void main()

{

  int i,j,k,m;

  clrscr();

  for(i=5;i>=1;i--)

  {

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

    {

      printf("%d",j);

    }

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

    {

      printf(" ");

    }

    for(m=i;m>=1;m--)

    {

      printf("%d",m);

    }

    printf("\n");

  }

  getch();

}

 

OUTPUT

 

1 2 3 4 5 5 4 3 2 1

1 2 3 4       4 3 2 1

1 2 3             3 2 1

1 2                   2 1

1                         1

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.