Hello,

I got folllowing code working but need to work on optimization.

Can anybidy help me in reducing number of loops?

main()

{

int height,i,j,k;

while ( getch() == 'c' )

{

printf("Enter the height of triangle\n");

scanf("%d",&height);

printf("Height = %d\n",height);

k = 1;

for ( i = 0; i < height; i++)

{

j = height-i-1;

while ( j--)

putch(' ');

for ( j = 0; j < k ; j++)

putch('*');

printf("\n");

k = k+2;

}

k = 1;

for ( i = 0; i < height; i++)

{

j = i;

while ( j--)

putch(' ');

for ( k = (((height-i)*2)-1); k ; k--)

putch('*');

printf("\n");

k = k-2;

}

printf("\n\n\n Press 'c' to continue\n");

}

}