C Program to Print an Equilateral Triangle

Write a program in the c programming language to print an equilateral triangle of the asterisks or by using any other character. Make this program by using for loop statements. Below is the triangle we have to print as a output of the program-


c program triangle

Output as Equilateral Triangle in the C program


Below is the code of the C program to print the above output –

/* C program to print Equilateral Triangle*/
#include<stdio.h>
main()
{
      int i,j,k,n;

      printf("Enter number of rows  of the triangle \n");
      scanf("%d",&n);

      for(i=1;i<=n;i++)
      {
              for(j=1;j<=n-i;j++)
              {
                      printf(" ");
              }
              for(k=1;k<=(2*i)-1;k++)
              {
                      printf("*");
              }
              printf("\n");
      }
      getch();
}

Ouput – Output will be exact as shown in the image above

yashan has written 69 articles

15 thoughts on “C Program to Print an Equilateral Triangle

    1. I am with you on both points. Knowing who the historical characters are absolutely adds to the sense of nostalgia and mystique about Paris that Gil feels. A scene that stands out is when Gil was planting the plot of The Exterminating Angel in Luis Bunuel’s head. I got a good laugh out of that exchange but I was the only person in the theater who seemed to get the reference (or I was just the only person obnoxiously laughing out loud). I also plan on giving Midnight in Paris another look later in the year. Thanks for commenting!

    2. Correct. Its silly to assume that every single man can beat every single girl. Its naive.Just as there are very weak men, there are very strong girls. The sexes are not always what they are meant to be. lol. I do martial arts and can defend myself. Of course i can beat most girls but im sure there are many women who can beat me up. We are talking about the whole world, where theres millions of women.

  1. rj says:

    WITH THE HELP OF TWO LOOPS..YOU BETTER DO THIS WAY
    #include
    void main()
    {
    int i,j;
    for(i=1;i<=4;i++)
    {
    for(j=1;j=(5-i))
    {
    printf(“*”);
    }
    else
    {
    printf(” “);
    }
    }
    printf(“\n”);
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>