Here is my code:
include
include
int main(void) {
int h; //gettin some input.
do
{
h = get_int();
printf("height:\n"); //prompting for input.
}
while (h <= 0 || h > 23); //set pyramid constraints.
for(int i = 0; i < h; i++) //incrementing for i
{
for(int j = 0; j < h-i-1; j++) //incrementing for j
{printf("%s", " "); //aligning right.
}
for(int k = 0; k < i+2; k++)
{printf("#"); //printing the hashes obvs.
}
printf("\n");// printing spaces obvs.
}
return 0;//gettin out.
}
** Can i do this more efficiently? Perhaps not having the whole thing feeding through the while loop? Can all the for conditions be put into the same statement? Could this be done with less ints/is there a more efficient way to express the ratio between spaces, #s and \ns? is there a library that has functionality like 'align right', 'center' &&|| 'align left'?
**
Many thanks in advance, you all rock. -jeremy.