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=1;i<=5;i++)

  {

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

    {

      if(i==j)

            printf("\t0");

      else if(i<j)

            printf("\t+1");

      else

            printf("\t-1");

    }

    printf("\n");

  }

  getch();

}

 

OUTPUT

 

        0       +1      +1      +1      +1

        -1      0       +1      +1      +1

        -1      -1      0       +1      +1

        -1      -1      -1      0       +1

        -1      -1      -1      -1      0

No comments:

Post a Comment

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