0

I'm trying to get my code to compile properly and it just won't. I know the code works when using a printf and scanf but now that I've changed it to get_int and printf it is not working properly. I believe the issue is in lines 12 ans 13, but why are my limits being ignored? How do I fix the problem so my code compiles as it should? enter image description here enter image description here

0

UPDATE: I am confused, the code as it is on the picture above does not work when I try it - not surprisingly.

You have initialized int h but ask for int height = get_int.

It works if you adjust them all either to h or to height - at least on my PC.

| improve this answer | |
  • I changed %d to %i and I will add the un-blackened screen shot. – Rayray94 May 19 at 21:06
0

On line 8, you set h = 0. Inside the do-while loop, you don't do anything to h, because you're working with a different variable, height. Then you check if h is between 1 and 8, but it's still 0 because you never do anything to it. h just always stays with the value 0.

Try editing your code so it only uses one variable for the height of the pyramid.

| improve this answer | |

You must log in to answer this question.

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