Web technology

web developers learning site

Archive for the tag “pyramid”

Display a pyramid

1. Write a program to display a pyramid as follow structure..

      *
*    *
*    *   *
*   *
*

int main()
{
int i,j,k,lmt=3;
for(i=1;i<=3;i++)
{
for(k=lmt-i;k>=1;k–)
printf(” “);
for(j=1;j<=i;j++)
printf(” *”);
printf(“\n”);
}

for(i=3-1;i>=1;i–)
{
for(k=lmt-i;k>=1;k–)
printf(” “);
for(j=1;j<=i;j++)
printf(” *”);
printf(“\n”);
}

return 0;
}

Post Navigation