## 8.26.2013

### Nested Star-Hash Pyramid

Q. Write a C program to print the following star-hash pyramid design:

#####*#####
####*#*####
###*###*###
##*#####*##
#*#######*#
*#########*

/**************************************************************
How To Make Above nested Pyramid C program
***************************************************************
So you can see, there are four types pyramid in above design as:

#####      *         #####
####      *#   *      ####
###      *##   #*      ###
##      *###   ##*      ##
#      *####   ###*      #
*#####   ####*

Hence, now it is easy to make these above pyramid program. So i recommended to make first above four pyramid program, after making these pyramid design, add these all pyramid in single C program and you are done. :) )
**************************************************************/

Ans.

/*c program for nested star-hash pyramid*/
#include<stdio.h>
int main()
{

int n=5,r,c;
for(r=1; r<=6; r++,n--)
{
/*first pyramid*/
for(c=1; c<=n; c++)
printf(" #");
/*second pyramid*/
for(c=1; c<=r; c++)
{
if(c==1)
printf(" *");
else
printf(" #");
}
/*third pyramid*/
for(c=r; c>1; c--)
{
if(c==2)
printf(" *");
else
printf(" #");
}
/*fourth pyramid*/
for(c=n; c>=1; c--)
printf(" #");
printf("\n");
}
getch();
return 0;
}

/*************************************************************
The output of above program would be:
**************************************************************/

 Figure : Screen shot for nested Hash-Star Pyramid C program

#### 1 comment:

1. How to make a program that will eliminate the middle two triangles?
i have made a code but it is a bit long as compare to above once.