Home » C programs

C program for 'Reverse Half Pyramid' Pattern



In this C program, we are implementing logic to print Reverse Full Pyramid pattern using asterisks and loops (nested loops).
Submitted by Shamikh Faraz, on February 16, 2018

In this program, we will learn, how we can print reverse full pyramid using ‘asterisks’ and ‘loops’.

C program

#include<stdio.h>

int main()
{
	int a,b,rows,space;

	printf("Enter number of rows");
	scanf("%d",&rows); 
	for(a=5; a>=1; a--)//decease number of rows
	{
		//print magin space 
		for(b=1; b<=space; b++) 
			printf(" ");
		
		//this loop prints half part of pyramid
		for(b=1; b<=a; b++) 
			printf("*");
		
		//this loop prints remaining half part of pyramid 
		for(b=a-1; b>=1; b--)
			printf("*");
		
		printf("\n");
		space++;
	}
	
	return 0;
}

Output

Output - Reverse full Pyramid Pattern






Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.



Comments and Discussions





© https://www.includehelp.com (2015-2018), Some rights reserved.




close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.