Header Ad

C Program to print star pattern in a pyramid shape

In this tutorial, we are going to write a C Program to print star patterns in a pyramid shape in C Programming with practical program code and step-by-step full complete explanation.

C Program to print star pattern in a pyramid shape


C Program to print star patterns in a pyramid shape.

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

void main()
{
	int i,j,k,m=3;

	clrscr();

	for(i=1;i<=3;i++)
	{
		for(j=1;j<=m-1;j++)
		printf(" ");
			
            for(k=1;k<=2*i-1;k++)
			printf("*");
		m--;
		printf("\n");
	}

	getch();
}


Output

 
  *
 ***
*****


Post a Comment

0 Comments