;

C Program to Print Half Inverted Pyramid using Asterisk (*)


Tutorialsrack 03/11/2019 C

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 (*).

Code - C Program to Print Half Inverted Pyramid using 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;
}
Output

Enter The Number of Rows: 5
* * * * *
* * * *
* * *
* *
*

--------------------------------
Process exited after 1.772 seconds with return value 0
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags