⭐📚Intermediate
Print Full Diamond Shape Pyramid
Print full diamond shape
A diamond pattern is a combination of a pyramid and an inverted pyramid.
Program Code
diamond_pattern.c
C
1#include <stdio.h>23int main() {4 int rows;5 6 printf("Enter number of rows: ");7 scanf("%d", &rows);8 9 // Upper half10 for (int i = 1; i <= rows; i++) {11 for (int j = 1; j <= rows - i; j++)12 printf(" ");13 for (int k = 1; k <= 2 * i - 1; k++)14 printf("*");15 printf("\n");16 }17 18 // Lower half19 for (int i = rows - 1; i >= 1; i--) {20 for (int j = 1; j <= rows - i; j++)21 printf(" ");22 for (int k = 1; k <= 2 * i - 1; k++)23 printf("*");24 printf("\n");25 }26 27 return 0;28}Output
Enter number of rows: 4
*
***
*****
*******
*****
***
*
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials