Spoiler alert code inside this link! !http://imgur.com/OIHvPFC

I am having trouble with the mario, any tips of how i can get on with this?

I have listed my integers at the start but maybe i over done it? while the rest of the code (the print side) is lagging behind?

That's what i think.

cheers in advance


You need to watch the lectures again as your code has a number of errors:

  1. While not wrong, you only need the stdio.h and cs50.h header file for this pset and can get rid of math.h.

  2. Check your variable declaration. The line

    int foo = 3; serves to assign an integer value, in this case 3, to the variable foo. Thus you can see that

    int height=GetInt(); is valid, but your declaration of space, hashe and line are wrong, as you equate them to a function for printing. What you can do though is declare them first and just assign them values later, like so:

    int space, hashe, line;

Just make sure not to include the variable type "int" later on when assigning later on since you've done that already.

  1. You want the line
    int height=GetInt(); to come after you prompt for user input, not before, so remove the earlier declaration.
  2. Finally, you need to figure out how many spaces and hashes should be printed on each level of the pyramid. Try to work out with pen and paper a simple equation relating the number of spaces and hashes on each level. Then use a combination of for loops, as you're already doing, to print out the spaces and hashes on each level.

Good luck.

  • well thank you very much for your rapid reply! i am gonna restart all again from scratch following your suggestions, one thing that you said and it completely unbalanced me was about the ''int foo = 3;'' erm what? after reading your post and reading my code again i seen a few little mistakes! which i will blame on being a dad of 4 for it :D – Euriloco Apr 23 '16 at 15:55
  • i'm glad you figured out what i was trying to say, i misspelled "assign", which i fixed now – ronga Apr 25 '16 at 3:32

You must log in to answer this question.

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