Pyramid Pattern Program in C

In this section you will learn how to print pyramid pattern in c in easy way. We will print the pyramid pattern with help of for loop condition and then we will show the output on screen. In this program we are taking the input from user.

Pyramid Pattern Program

How program will work?

Program of print pyramid pattern in c


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

	//PYRAMID PATTERN PROGRAM
	void main()
	{
   	   int value, i, j, k;
	   clrscr();
	   
	   printf("PROGRAM FOR DISPLAYING PYRAMID PATTERN OF *.");
	   printf("ENTER NUMBER TO PRINT THE PYRAMID:- ");
	   scanf("%d",&value);
	   
	   for(i=1; i<=value; i++)
	   {
	   	for(j=0; j<=(value-i); j++)
		{
		    printf(" ");
		}
		
		for(j=1; j<=i; j++)
		{
		    printf("*");
		}
		for(k=1; k<i k++)
		{
		   printf("*");
		}
		printf("\n");
	   }
	   	   
	   getch();
	 }

Output:


	PROGRAM FOR DISPLAYING PYRAMID PATTERN OF *.
	ENTER NUMBER TO PRINT THE PYRAMID:- 5
	
            *
          * * *
        * * * * *
      * * * * * * *
    * * * * * * * * *

Post Your Comment