;

C Program To Print Inverted Full Pyramid Using an asterisk (*)


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print an inverted full pyramid using an asterisk (*).

Here is the code of the program to print an inverted full pyramid using an asterisk (*).

Code - C Program To Print an Inverted Full Pyramid Using an asterisk (*)
/*
C Program To Print Inverted Full Pyramid Using an asterisk (*)

* * * * * * * * *
  * * * * * * *
    * * * * *
      * * *
        *
*/

#include<stdio.h>
int main()
{
    int rows, i, j, space;
    printf("Enter number of rows: ");
    scanf("%d",&rows);
    for(i=rows; i>=1; --i)
    {
        for(space=0; space < rows-i; ++space)
            printf("  ");
        for(j=i; j <= 2*i-1; ++j)
            printf("* ");
        for(j=0; j < i-1; ++j)
            printf("* ");
        printf("\n");
    }
    return 0;
}
Output

Enter number of rows: 5
* * * * * * * * *
  * * * * * * *
   * * * * *
    * * *
     *

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


Related Posts



Comments

Recent Posts
Tags