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 3



#include

main()
{
      char ch = 'A';
      int n, c, k, space = 0;
      clrscr();
      printf("Enter Number of Rows..");

      scanf("%d", &n);

      for ( k = n ; k >= 1 ; k-- )
      {
          for ( c = 1 ; c <= space ; c++)
              printf(" ");

          space++;

          for ( c = 1 ; c <= k ; c++ )
          {
             printf("%c ", ch);
             ch++;
          }

          printf("\n");
          ch = 'A';
      }
      getch();

      return 0;
}

--------------------------------
Output:-
Enter Number of Rows..6
A B C D E F
 A B C D E
  A B C D
   A B C
    A B
     A

















No comments: