Diamond Pyramid of ” * ” & Numbers

This C program print the Diamond Pyramid of ” * ” & Number. (for number just replace Stars (*) with their interator (I) in a loop.

    *
***
*****
*******
*********
*******
*****
***
*

C program to print Diamond Pyramid of ” * ” & Numbers

C




#include <stdio.h>
 
int main() {
    int n = 5;
 
    // Print the top pyramid
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - i; j++) {
            printf(" ");
        }
        for (int k = 1; k <= 2 * i - 1; k++) {
            printf("*");
        }
        printf("\n");
    }
 
    // Print the inverted pyramid
    for (int i = n - 1; i >= 1; i--) {
        for (int j = 1; j <= n - i; j++) {
            printf(" ");
        }
        for (int k = 1; k <= 2 * i - 1; k++) {
            printf("*");
        }
        printf("\n");
    }
 
    return 0;
}


Output

    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *


C Program to Print Pyramid Pattern

Pyramid pattern printing is a very popular logical program and it enhances your logical thinking. In this article, we will learn how to make different types of pyramid patterns in c programming.

Similar Reads

Pyramid Pattern

A pyramid is a 3 – dimensional shape that has a polygon base and the sides of the pyramid look like a triangle shape. Pyramid pattern printing is a logical program by which we can develop logical thinking in programming. We can use conditional statements and loop concepts for making pyramid patterns. Pyramid patterns can be printed using numbers, characters, and special characters like stars....

1. Half Pyramid Pattern of Numbers

Half pyramid pattern of numbers looks like a right-angle triangle of numbers in which the hypotenuse is on the right side....

2. Inverted Half Pyramid of Numbers

...

3. Full Pyramid Pattern of Numbers

An inverted half-pyramid pattern of numbers is 180° reversed version of half pyramid pattern....

4. Full Pyramid of Numbers  in 180 Degree

...

5. hollow pyramid of ” * ” & Numbers

A full pyramid pattern of numbers is similar to an equilateral triangle....

6. Diamond Pyramid of ” * ” & Numbers

...

FAQs on “print pyramid in c”

This pattern can be printed by combining half pyramid pattern and an inverted half-pyramid pattern....