Most Important Pyramid Pattern programs

ProgrammingPattern Programs

 

Below are the various examples of pyramid patterns that are made using the combination of stars and the combination of numbers. This pyramid includes an inverted pyramid, full pyramid, left and right half pyramid, etc. And the program to print that pyramids

Concepts used to print Pyramid patterns are

  • For Loop
  • While Loop
  • if..else

 

1). Program to print half pyramid pattern using star(*)

#include<stdio.h>
#include<conio.h>
int main()
{    
	int i,j,n;
	printf("Enter the number of rows for half pyramid: ");
	scanf("%d",&n);
		for(i=1;i<=n;i++){
		    for(j=1;j<=i;j++){
                    printf("*");
		    }
		printf("\n");
	    }
	getch();
}

 

Output

 

2). Program to print inverted half pyramid pattern using star(*)

#include<stdio.h>
#include<conio.h>
int main()
{    
	int i,j,n;
	printf("Enter the number of rows for half pyramid: ");
	scanf("%d",&n);
		for(i=n;i>=1;i--){
		    for(j=i;j>=1;j--){
                        printf("*");
		    }
		    printf("\n");
	    }
	getch();
}

 

Output


You are offline, Please check your internet connection.

You are back online.