Print Pyramid Star Patterns – C Program

Pyramid Star Patterns – C Program

Pyramid Star Patterns C Program

#include <stdio.h>
#include<conio.h>

void main()
{
    int i, j, k;
    for(i=1;i<=5;i++)
    {
        for(j=i;j<5;j++)
        {
            printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("*");
        }
        printf("\n");
    }

}

The out put of pyramid  c program is :
Pyramid Star Patterns C Program *
***
*****
*******
*********

 

Revers Pyramid Star Patterns C Program

#include <stdio.h>
#include <conio.h>

void main()
{
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=5;j>i;j--)
        {
                printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("*");
        }
        printf("\n");
    }

}

The out put of revers pyramid star patterns in c program :

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

 

Triangle star patterns  C Program

#include <stdio.h>
#include <coino.h>

void main()
{
    int i, j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("*");
        }
        printf("\n");
    }

}

The out put of star triangle is :

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

 

Inverted star triangle patterns C Program

#include <stdio.h>
#include <conio.h>

void main()
{
    int i, j;
    for(i=5;i>=1;i--)
    {
        for(j=1;j<=i;j++)
        {
            printf("*");
        }
        printf("\n");
    }

}

The out put of inverted triangle patterns is :

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

 

Right side Triangle star patterns C Program

#include <stdio.h>
#include<conio.h>

void main()
{
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=1;j<i;j++)
        {
            printf(" ");
        }
        for(k=5;k>=i;k--)
        {
            printf("*");
        }
        printf("\n");
    }
}

The out put of right side triangle star patterns is :

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

 

Inverted Right side Triangle star patterns C Program

#include <stdio.h>
#include <conio.h>

void main()
{
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=5;j>i;j--)
        {
            printf(" ");
        }
        for(k=1;k<=i;k++)
        {
            printf("*");
        }
        printf("\n");
    }
}

The out put of inverted right side star patterns is :

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

 

Author: Meera Academy

Leave a Reply

Your email address will not be published. Required fields are marked *