About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Saturday, December 10, 2011

Pattern Printing 7



#include

void main()
{
      int n, c, d, num = 1, space;
      clrscr();
      printf("Enter the number of rows::");
      scanf("%d",&n);

      space = n - 1;

      for ( d = 1 ; d <= n ; d++ )
      {
          num = d;

          for ( c = 1 ; c <= space ; c++ )
              printf(" ");

          space--;

          for ( c = 1 ; c <= d ; c++ )
          {
              printf("%d", num);
              num++;
          }
          num--;
          num--;
          for ( c = 1 ; c < d ; c++)
          {
              printf("%d", num);
              num--;
          }
          printf("\n");

      }
      getch();

}


-----------------------------------
output:-
Enter the number of rows::6
     1
    232
   34543
  4567654
 567898765
67891011109876

















No comments: