Tuesday, 28 January 2014

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

No comments:

Post a Comment