c program to print pyramid



c program to print pyramid figure with * or asterisk – one

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

int main()
{
    for(int i=0; i<=5; i++)
    {
            for(int j=0; j<i; j++)
            {
                    printf(" * ");
            }
            printf("\n");
    }
    getch();
}


print pyramid

print pyramid

c program to print pyramid figure with * or asterisk – two

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

int main()
{
    for(int i=5; i>=0; i--)
    {
            for(int j=i; j>0; j--)
            {
                    printf(" * ");
            }
            printf("\n");
    }
    getch();
}


print pyramid

print pyramid

c program to print given pyramid with * or asterisk – Three

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

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


print pyramid

print pyramid

c program to print pyramid figure with * or asterisk – Four

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

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


print pyramid

print pyramid

c program to print pyramid figure with * or asterisk – Five

#include<stdio.h>
#include<conio.h>
int main()
{
    int  i, k;
    for ( i = 1 ; i <= 5 ; i++)
    {
        for ( k = 1 ; k <= i ; k++ )
            printf("*");

        printf("\n");
    }

    for ( i = 5 - 2 ; i>= 0 ; i-- )
    {
        for ( k = i ; k >= 0 ; k-- )
            printf("*");

        printf("\n");
    }

    getch();
}


print pyramid

c program to print pyramid figure with * or asterisk – Six

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

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


print pyramid

print pyramid

c program to print pyramid figure with * or asterisk – Seven

#include<stdio.h>
#include<conio.h>
int main()
{
    int  i, k, l;
    for ( i = 0 ; i <= 5 ; i++)
    {
            for(int k=1; k<=5-i; k++)
            {
                    printf(" ");
            }
            for(int j=0; j<i; j++)
            {
                    printf("*");
            }
            printf("\n");
    }

    for ( i = 5 - 2 ; i>= 0 ; i-- )
    {
        for( l=3-i; l>=0; l--)
        {
             printf(" ");
        }
        for ( k = i ; k >= 0 ; k-- )
        {
            printf("*");
        }
        printf("\n");
    }

    getch();
}


c program to print pyramid

c program to print pyramid

c program to print pyramid figure with * or asterisk – Eight

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

int main()
{
    for(int i=1; i<=10; i=i+2)
    {
            for(int k=1; k<=10-i; k=k+2)
            {
                    printf(" ");
            }
            for(int j=1; j<=i; j++)
            {
                    printf("*");
            }
            printf("\n");
    }
    getch();
}


c program to print pyramid

c program to print pyramid

c program to print pyramid figure with * or asterisk – Nine

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

int main()
{
    for(int i=1; i<=10; i=i+2)
    {
            for(int k=1; k<=10-i; k=k+2)
            {
                    printf(" ");
            }
            for(int j=1; j<=i; j++)
            {
                    printf("*");
            }
            printf("\n");
    }
    for(int i=9; i>=1; i=i-2)
    {
            for(int k=10-i; k>=0; k=k-2)
            {
                    printf(" ");
            }
            for(int j=1; j<=i; j++)
            {
                    printf("*");
            }
            printf("\n");
    }                
    getch();
}


Output :

c program to print pyramid

c program to print pyramid figure with * or asterisk – Ten

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

int main()
{
    for(int i=9; i>=1; i=i-2)
    {
            for(int k=10-i; k>=0; k=k-2)
            {
                    printf(" ");
            }
            for(int j=1; j<=i; j++)
            {
                    printf("*");
            }
            printf("\n");
    }
    getch();
}


c program to print pyramid

c program to print pyramid




"Please Do Like Facebook Page and follow us on Twitter so that you can actively participate and develop skills in programming. If you find above post interesting do share the webpage."
This entry was posted in c program and tagged , . Bookmark the permalink.

8 Responses to c program to print pyramid

  1. thanks you sir but i can not understant why you use
    for(int k=10-i; k>=0; k=k-2)
    {
    printf(” “);
    }
    this for loop i cant understand please understand about that .
    thanks you

  2. creating pyramid of numbers is the basic lab c program used in many institutions. Thank you for sharing this program.
    regards:
    srinath reddy.
    admin of Programming Tutorials for Beginners

  3. good and easy to understand
    thank you!!!!!!!!!!!

  4. Palash Nandi says:

    sir i have a one question. That is when user want to give no. of row is visible at his choice then what we have done??

  5. saba says:

    thanks alot

  6. saba iftkhar says:

    thanks a lot

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>