In this C program, we will learn how to write a program to print the half inverted pyramid using an asterisk (*).
Here is the code of the program to print the half inverted pyramid using an asterisk (*).
/*
C Program to Print Inverted half pyramid using Asterisk (*)
* * * * *
* * * *
* * *
* *
*
*/
#include <stdio.h>
int main()
{
int i, j, rows;
printf("Enter The Number of Rows: ");
scanf("%d",&rows);
for(i=rows; i>=1; --i)
{
for(j=1; j<=i; ++j)
{
printf("* ");
}
printf("\n");
}
return 0;
}
Enter The Number of Rows: 5
* * * * *
* * * *
* * *
* *
*
--------------------------------
Process exited after 1.772 seconds with return value 0
Press any key to continue . . .
Comments