9.01.2011

4.Design triangle pyramid

Q. Write a program to generate a following #'s triangle?
                   
#



# #


# # #

# # # #
# # # # #
Ans.

/* c program for symbol triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int num,r,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; num>=r; r++)
 {
  for(c=1; c<=r; c++)
     printf("#");
  printf("\n");
 }
 getch();
 return 0;
}

/*************OUTPUT**************
Enter loop repeat number(rows): 5

#



##


###

####
#####

***********************************/

15 comments:

  1. print pattern of stars
    *
    ***
    ******

    ReplyDelete
    Replies
    1. Your required star pattern source code at:

      http://cprogrammingcodes.blogspot.in/2012/10/star-pyramid-pattern.html

      Delete
  2. Get the marks of student and print the average marks...
    plzzzzzzzzzz tell me urgently

    ReplyDelete
    Replies
    1. Your required student gets marks, calculate percentage and division C program at:

      http://cprogrammingcodes.blogspot.in/2012/10/get-student-marks-and-calculate.html

      Delete
  3. *
    * *
    * * *
    * *
    *
    Plz tell me the source for this o/p

    ReplyDelete
    Replies
    1. @Uma,
      Your required program source code at:

      http://cprogrammingcodes.blogspot.in/2012/11/star-pyramid.html

      Delete
  4. Design a program that will display a triangle using ‘*’ characters. The user is to be prompted to enter the number of rows to be displayed within the range 3-9, the
    program should loop continuously using a do-while loop until a valid number of rows has been
    entered.

    ReplyDelete
  5. Replies
    1. @Ghazanfar,

      your required program source code at:

      http://cprogrammingcodes.blogspot.in/2011/09/10design-numbers-tringle-pyramid.html

      Delete
  6. Replies
    1. #include
      main()
      {
      int i,j,k,n;
      printf("Enter the number of rows");
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
      for(k=n;k>i;k--)
      {
      printf("0");
      }
      for(j=0;j<i;j++)
      {
      printf("*");
      }

      printf("\n");
      }
      }

      Delete
  7. hi there, i really2 need your help to print this output by using function prototype.

    *
    **
    ***
    #
    ##
    *
    **
    ***

    ReplyDelete
  8. #include
    main()
    {
    int i,j,k,n;
    printf("Enter the number of rows");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    /* for(k=1;k<i;k++)
    {
    printf(" ");
    }*/
    for(j=1;j<=i;j++)
    {
    printf("#");
    }

    printf("\n");
    }
    }

    ReplyDelete
  9. can you make the flowchart for "*" pyramid?..plz snd anyone

    ReplyDelete
  10. please tell me its algorithm
    *
    * *
    * * *
    * * * *
    * * * * *

    ReplyDelete