Polyhedral Dice and Pyramid pattern Program in C

Hello Student in this example,  today you will learn how to print Polyhederal pyramids in C, Using For( ) loop
before understanding this program you need to learn Number Pattern Program (click)

Star Pattern in C

#include<stdio.h>
void print (int);

int main () {
int rows;

printf("Enter Size of Polyhedral pattern:-");

scanf("%d", &rows);

print(rows);

return 0;
}

void print (int r) {
int c, space;
static int stars = -1;

if (r <= 0)
return;

space = r - 1;
stars += 2;

for (c = 0; c < space; c++)
printf(" ");

for (c = 0; c < stars; c++)
printf("*");

printf("\n");

print(--r);

space = r + 1;
stars -= 2;

for (c = 0; c < space; c++)
printf(" ");

for (c = 0; c < stars; c++)
printf("*");

printf("\n");
}

 

Hollow parallelogram Star pattern (clikhere)

Rectangle Pattern Programm in C (clikhere)

Pyramid pattern program in c

Output
Enter Size of Polyhedral pattern:- 4

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

Rectangle Pattern program in C

Polyhedral Dice and Pyramid pattern Program in C
Polyhedral Dice and Pyramid pattern Program in C

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.