Pattern 3 :C Program to print Star pattern | Triangle star pattern program.

Spread the love

Introduction:

Let’s write a C Program to print the Reverse Triangle pattern (star). This pattern contains the stars and spaces. It is right angle triangle.

This program asks for input from the user. Depending on the input, It will print the triangle upto that size. For example, If the user input is 5. Then it will print the triangle upto the five rows, Starting from row one.

In the row 1, It will print one star, In the row 2 it will print two stars, So on. At the row 5 it will print 5 stars. Here is the pattern for input value of 5.

reverse-triangle-star-pattern-in-c

 

Pattern 3 : Write a C Program to print below pattern ( Triangle Star pattern with spaces).

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

 

Reverse Triangle Star Pattern Program :

  1. #include<stdio.h>
  2. int main()
  3. {
  4.         int i,j,n;
  5.         printf(“Enter how many rows you want: “);
  6.         scanf(“%d”,&n);
  7.  
  8.         for(i=1;i<=n;i++)
  9.         {
  10.                 for(j=1;j<=(ni);j++)
  11.                         printf(”  “);   // two spaces
  12.  
  13.                 for(j=1;j<=i;j++)
  14.                         printf(” *”);
  15.  
  16.                 printf(“\n);
  17.         }
  18.         return 0;
  19. }

Output :

Output of star pattern program

Similar Star pattern programs:

Also See:

Venkat

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

1 Response

  1. June 24, 2021

    […] Pattern 3: Reverse Triangle Star Pattern Program […]

Leave a Reply