0

Please can someone assist me! I have been stuck on this for a few hours. I can't seem to make the "#" print and loop to resemble a pyramid.

I tried many different ways I could figure out but no success. Your time and help will be appreciated!

My code:

include

include

int get_positive_int(void);

int main(void)

{ int i = get_positive_int(); printf("%i\n", i); }

// Prompt user for positive integer

int get_positive_int(void) { int b; do { b = get_int("Height: ");

}
while (b > 7);

for (int i = 1; i <= 7 ; i++)
{
    printf("%d\n", b);
    b++;



}

return b;

}

1

Remember that what you actually want to print are the characters # and the spaces. Also, a variable defined within a function cannot be called from outside of this curly brackets. Also, decide whether your pyramid height variable is i or is b?

| improve this answer | |
  • Thank you so much Johann, I will have a look at the code again based on your advice above. – Candice Apr 23 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .