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.
Prerequisites: