C Program to Print Triangle of Stars

Write a program in the C programming language to print the triangle of stars. Make a right angled triangle. You can also print any other character of your choice.  Below is the pattern of the triangle-


*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *



This C program is made by using the nested for loops to print asterisks . Below is the code of the program-

/* C program to print triangle of stars or of any other character */

#include<stdio.h>
void main()
{
     int n,i;

     for(n=1;n<=20;n++)
     {
             for(i=1;i<=n;i++)
             {
                     printf("*");
             }
             printf("\n");
     }
     getch();
}

Output – Output will be same as the triangle made above

yashan has written 70 articles

3 thoughts on “C Program to Print Triangle of Stars

  1. Emma says:

    I like the valuable inomofatirn you supply in your articles. I will bookmark your blog and take a look at again here regularly. I’m quite sure I’ll be informed many new stuff right right here! Best of luck for the following!

  2. No, the sweater was from dressbarn! (Handbag from Urban Outfitters of all places.:-)You can post cool stuff you found to your blog & send me a link…or email me carlyjcais AT hotmail DOT com if you are so inclined.Thanks for all your comments:-)xoxoCarly

  3. Thank you for making the sincere attempt to speak about this on rknlczweblog.com . I feel very strong about it and would like to read more. If it’s OK, as you achieve extra extensive wisdom, may you mind including extra articles similar to this one with additional info? It will be extraordinarily useful and helpful for me and my friends.

Cancel reply

Leave a Reply to Emma

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>