//1>program for piramid.
---------------------------
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,a,k=0,m;
clrscr();
scanf("%d",&n);
m=n*2;
a=m/2;
for(i=0;i<m;i++){
printf("\n");
if(i<a)k++;
else k--;
for(j=0;j<m;j++){
if(i>=a||j<a-(k-1)||j>a+(k-1))
printf(" ");
else
printf(" *");
}
}
getch();
}
//2>program for Revrse piramid.
---------------------------
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,a,k=0,m;
clrscr();
scanf("%d",&n);
m=n*2;
a=m/2;
for(i=0;i<m;i++){
printf("\n");
if(i<a)k++;
else k--;
for(j=0;j<m;j++){
if(i<a||j<a-(k-1)||j>a+(k-1))
printf(" ");
else
printf(" *");
}
}
getch();
}
//3>program for combind both piramid and Reverse Piramid.
---------------------------
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,a,k=0,m;
clrscr();
scanf("%d",&n);
m=n*2;
a=m/2;
for(i=0;i<m;i++){
printf("\n");
if(i<a)k++;
else k--;
for(j=0;j<m;j++){
if(j<a-(k-1)||j>a+(k-1))
printf(" ");
else
printf(" *");
}
}
getch();
}
output...........
for progaram 1
--------------------
*
***
*****
*******
------------------------
for progaram 2
--------------------
*******
*****
***
*
------------------------
for progaram 3
--------------------
*
***
*****
*******
*****
***
*
------------------------
dharma117 -6 Newbie Poster
Adak 419 Nearly a Posting Virtuoso
arindam31 commented: That was great suggestion.....Ill try to follow these from now on... +0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.