C Exercises: Display the pattern like a pyramid containing odd number of asterisks
20. Pyramid Pattern with Odd Asterisks
Write a C program to display the pattern as a pyramid using asterisks, with each row containing an odd number of asterisks.
The pattern is as below:
* *** *****
This C program generates a pyramid pattern using asterisks, with each row containing an odd number of asterisks centered to form a pyramid shape. The program prompts the user to input the number of rows and then uses nested loops to print spaces and asterisks in the required pattern.
Visual Presentation:

Sample Solution:
C Code:
Output:
Input number of rows for this pattern :5 * *** ***** *******
Flowchart

For more Practice: Solve these Related Problems:
- Write a C program to display a centered pyramid where each row contains an odd number of asterisks.
- Write a C program to display an inverted pyramid with odd-numbered asterisk counts.
- Write a C program to print a pyramid of asterisks and then compute the total number of asterisks used.
- Write a C program to display a pyramid of asterisks and then mirror the pattern vertically.
C Programming Code Editor:
Previous: Write a program in C to display the n terms of harmonic series and their sum.
Next: Write a program in C to display the sum of the series [ 9 + 99 + 999 + 9999 ...].
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.