below is one simplest code to illustare the pyramid of number.
void piramid(int const c)
{
int r, x;
for (r = c; r > 0; r--)
{
for (x = 1; x < = (2 * c - r); x++)
{
if (x < r) printf(" ");
else if (x <= c) printf("%d", x - r + 1);
else printf("%d", (2 * c - r) - x + 1);
}
printf("\n");
}
}
is there any other method that uses just the loop counters to print the pyramid with out the help of any other variables.
i just want to replace the statements x - r + 1
and (2 * c - r) - x + 1
by just r or x.
Thanks ,