********* ******* ***** *** *
Required knowledge:
Basic C programming, For loopLogic:
The above pattern is similar to the simple pyramid star pattern in reversed order. To print this we need not to make much changes in simple pyramid star pattern we only need to reverse the loop conditions of the outer loop.Program:
/** * C program to print reverse pyramid star pattern */ #include <stdio.h> int main() { int i, j, n; //Reads number of rows to be printed from user printf("Enter value of n : "); scanf("%d", &n); for(i=n; i>=1; i--) { //Prints trailing spaces for(j=i; j<n; j++) { printf(" "); } //Prints reverse pyramid for(j=1; j<=(2*i-1); j++) { printf("*"); } printf("\n"); } return 0; }
Output
Enter value of n: 5
*********
*******
*****
***
*
*********
*******
*****
***
*
Screenshot:
Happy coding ;)
You may also like
- All star patterns programs index.
- For loop programming exercises and solutions.
- If else programming exercises and solutions.
- C program to check whether a triangle is Equilateral, Scalene or Isosceles.
- C program to check whether a triangle is valid or not.
- C program to convert Binary to Decimal number system.
- C program to convert Octal to Decimal number system.
- C program to convert Decimal to Binary number system.
- C program to convert Hexadecimal to Octal number system.
- C program to print Pascal triangle of n rows.
- C program to print fibonacci series.
- C program to check whether a number is Prime number or not.