pattern 10: C Program to print triangle Star pattern

Spread the love

Write a C Program to print below pattern :

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

Note: This is one the Series of pattern programs in C.

Program :

  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,j,k,n;
  5.     printf(“Enter the Value for n : “);
  6.     scanf(“%d”,&n);
  7.  
  8.     for(i=-n;i<=n;i++) // Note that ‘i’ is starting from -n (negative n)
  9.     {
  10.         k=i;
  11.         for(j=0;j<=n;j++)
  12.         {
  13.             if(k<=j)
  14.                 printf(“* “);
  15.             else
  16.                 printf(” “);
  17.         }
  18.         printf(n);
  19.     }
  20.         return 0;
  21. }

Output:

Similar Star pattern programs:

More C programs:

C Tutorials with simple Examples:



Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply