Write C Program to Print Inverted Half Pyramid of Stars Pattern

 https://webdesigningtheory.blogspot.com/2025/06/c-program-to-print-alphabet-t-star.html

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Example 


#include<stdio.h>
void main ()
{
int i,j,r;
printf("enter the number");

scanf("%d",&r);

for(i=r;i>=1;i--)

{
for(j=1;j<=i;j++)

{

printf("*");

}

printf("\n");

}

return 0;

}



Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Explain Program

Step :1

#include <stdio.h>

  • standard input-output library, printf() and scanf() function

Step :2

void main()

  • starting point of the program.

Step :3

. int i, j, r;

  • Declares three integer variables:
  • r: the number of rows (input from the user).
  • i: used for the outer loop (rows).
  • j: used for the inner loop (columns/asterisks per row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows for the triangle.

Step :5

for(i = r; i >= 1; i--)

  • Starts at i = r and decrements to 1.
  • First row has r stars,
  • Second row has r-1 stars,

Step :6

for(j = 1; j <= i; j++)

{

    printf("*");

}

  • row, prints i number of asterisks (*).
The number of asterisks decreases as i decreases

Step :7

printf("\n");

  •  cursor to the next line after each row of asterisks.

Step :8

return 0;

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

 Program Output :- 

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern


Related Post :-

number pattern program C

C program print square star pattern

Free online learn C programming course


Comments

Popular posts from this blog

how to add background image in html.

HTML pre tag

How to insert image in html

Html anchor tag

Inline css in html