Iam3R 24 Junior Poster

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 ,

WaltP commented: Adter 80+ posts, don't you think it's time to learn how to FORMAT code? -2
Iam3R 24 Junior Poster

But, is there any proposed solution to what I'm looking for?

you can also use function pointers to do same thing.

Iam3R 24 Junior Poster

please provide the free pdf link of k & R c prog lang.

i spent lot of time in googling but couldnot get it.

thanks in adv.

Iam3R 24 Junior Poster

if i use this in a program its keep on taking the return key
the program not getting terminated, whats the problem?

scanf("%d\n",&j)