Subscribe

RSS Feed (xml)

Tuesday, November 10, 2009

Write a C program to print the Given pyramid

     1
    1 2 
   1 2 3  
  1 2 3 4
 1 2 3 4 5
  .
  .
  .
  n


#include(stdio.h) // note place '<' & '>' in place of '(' & ')'
#include(conio.h)
int main( )
{
int r,c,n,sp;
clrscr( );
printf("Enter the no. of rows u want to print:");
scanf("%d", &n);
for(r=1; r<=n; r++)
{
for(sp=n; sp>=r; sp--)
printf(" "); // give one space in betw quotations.
for(c=1; c<=r; c++)
printf("%2d", c);
printf("\n");
}
getch( );
return 0;
}

12 comments:

  1. write a progam in c language to print
    A B C D E F G F E D C B A
    A B C D E F F E D C B A
    A B C D E E D C B A
    A B C D D C B A
    A B C C B A
    A B B A
    A A

    ReplyDelete
    Replies

    1. Write a C program to print the Given pyramid
      ► October (9)
      ► August (1)
      ► July (10)
      ► June (3)
      ► May (1)
      ► February (15)
      ► January (16)
      FOLLOWERS


      SUBSCRIBE NOW: IHEART

      I heart FeedBurner


      SUBSCRIBE

      RSS Feed (xml)

      Tuesday, November 10, 2009
      Write a C program to print the Given pyramid
      1
      1 2
      1 2 3
      1 2 3 4
      1 2 3 4 5
      .
      .
      .
      n


      #include(stdio.h) // note place '<' & '>' in place of '(' & ')'
      #include(conio.h)
      int main( )
      {
      int r,c,n,sp;
      clrscr( );
      printf("Enter the no. of rows u want to print:");
      scanf("%d", &n);
      for(r=1; r<=n; r++)
      {
      for(sp=n; sp>=r; sp--)
      printf(" "); // give one space in betw quotations.
      for(c=1; c<=r; c++)
      printf("%2d", c);
      printf("\n");
      }
      getch( );
      return 0;

      Delete
  2. write a progam in c language to print
    A B C D E F G F E D C B A
    A B C D E F F E D C B A
    A B C D E E D C B A
    A B C D D C B A
    A B C C B A
    A B B A
    A A

    ReplyDelete
  3. A B C D E F G F E D C B A
    A B C D E F F E D C B A
    A B C D E E D C B A
    A B C D D C B A
    A B C C B A
    A B B A
    A A

    ReplyDelete
  4. ABCDEFGFEDCBA
    ABCDEF FEDCBA
    ABCDE EDCBA
    ABCD DCBA
    ABC CBA
    AB BA
    A A

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. write a prog :~
    A
    BB
    CCC
    DDDD
    EEEEE
    FFFFFF
    GGGGGGG
    HHHHHHHH
    IIIIIIIII
    JJJJJJJJJJ
    KKKKKKKKKKK
    LLLLLLLLLLLL
    MMMMMMMMMMMMM
    NNNNNNNNNNNNNN
    OOOOOOOOOOOOOOO
    PPPPPPPPPPPPPPPP
    QQQQQQQQQQQQQQQQQ
    RRRRRRRRRRRRRRRRRR
    SSSSSSSSSSSSSSSSSSS
    TTTTTTTTTTTTTTTTTTTT
    UUUUUUUUUUUUUUUUUUUUU
    VVVVVVVVVVVVVVVVVVVVVV
    WWWWWWWWWWWWWWWWWWWWWWW
    XXXXXXXXXXXXXXXXXXXXXXXX
    YYYYYYYYYYYYYYYYYYYYYYYYY
    ZZZZZZZZZZZZZZZZZZZZZZZZZZ

    ReplyDelete
  7. Hi,
    Can u pls tell me the program for this kind of output:

    ABCDEFEDCBA
    ABCDE EDCBA
    ABCD DCBA
    ABC CBA
    AB BA
    A A

    ReplyDelete
  8. sorry i meant to say this output:

    ABCDEFEDCBA
    ABCDE EDCBA
    ABCD DCBA
    ABC CBA
    AB BA
    A A

    ReplyDelete
  9. ABCDEFEDCBA
    ABCDE EDCBA
    ABCD DCBA
    ABC CBA
    AB BA
    A A

    plz give c code for this

    ReplyDelete
  10. PLS GIVE C CODE FOR THIS OUTPUT
    A B C C B A
    A B B A
    A A
    A B B A
    A B C C B A

    ReplyDelete
  11. A B C C B A
    A B B A
    A A
    A B B A
    A B C C B A

    ReplyDelete