Sunday 19 August 2012

c program code for draw pyramid

How to Draw Pyramid pattern in c language

/* To print Pyramid Pattern shown below

Pyramid Pattern

*/

int main()
{
int i,j,n;
printf("Enter no. of lines: ");
scanf( "%d",&n);
//for loop for upper pyramid
//for loop for number of lines
for(i=1;i<=n;i++)
{
//for loop for spaces
for(j=1;j<=n-i;j++)
{
printf(" ");
}
//for loop for stars in first half
for(j=1;j<=i;j++)
{
printf("* ");
}
//for loop for stars in second half


//for loop for lower pyramid

//for loop for number of lines

for(i=1;i<=n-1;i++)
{
//for loop for spaces
for(j=1;j<=i;j++)
{
printf(" ");
}
//for loop for stars in first half
for(j=1;j<=n-i;j++)
{
printf("* ");
}
//for loop for stars in second half


return 0;

}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: