2

I'm really struggling with the First Problem Set 1 'Mario.

Can somebody please just give me a hint as to where to start or where I can do more research? (Just Purchased Absolute Beginners Guide to C 3rd edition, will this book help?)

4
  • Did you try searching for pset1 or mario?
    – kzidane
    Sep 29 '14 at 19:21
  • Without knowing anything about what you have already tried or where you are stuck, it's difficult to answer. I did a lengthy write-up for another user here that you might find helpful. Otherwise I can recommend asking on Facebook or reddit, where there are private message systems for one-on-one discussion.
    – Air
    Sep 29 '14 at 23:37
  • Have you tried something already? Can you post here what have you done so far?
    – user2477
    Oct 1 '14 at 10:38
  • Hi Alexandr; No I haven't tried anything yet! I'm in a bit of a blind panic... lot's of white space and I just don't know where to start - I've gone through the walkthrough's and still my brain has frozen.?!?!
    – Anne
    Oct 1 '14 at 15:02
5

If the white space on the screen intimidates you, try outlining the problem on scrap paper. Think in broad terms, and describe what you're going to do in plain English before you write the code. Think in very small steps or instructions.

Then try to figure out the code for one of those instructions. You might try doing a simple math calculation and printing the result on the screen. Do each little thing separately until you start to see how they fit together.

For example in Mario, you know you have to print out different numbers of characters to make a pyramid. You could start with a simpler problem: Ask the user for a number, and then have the program repeat the same number back to them.

A little harder: Ask the user for a number, and then have the program print some character that many times in a row.

A little harder: Ask the user for a number, and then have the program print out a square made of zeros or ones or whatever character you like. If they put in 3, you should print a 3x3 square.

By this point you will be more than halfway there.

2
  • Thank you so much for all your help! - It is truly appreciated, when I finish work I'll go through both of your options ... Thanks Again
    – Anne
    Oct 3 '14 at 18:27
  • Upvote and accept if the suggested answer worked for you, that's always better than plain thanks.
    – sinister
    Oct 4 '14 at 17:24
2

Start by writing a simple piece of code that asks the user for input. You can reuse your "Hello, World!" code for this and change the printf statement to ask the user for a pyramid height.

After that, you are going to need to figure out how to declare an integer variable and use the GetInt() function to get an integer from the user and store it in your variable.

After that, you might want to run a little check on what your user just entered to make sure it's valid and within the right range. You'll probably want a loop here that keeps running and bugging the user for input until they enter a value that is between the acceptable range.

After that...well, let's get there first! :)

0

Here is a little beginning: First think about valid inputs. Can a user put in 3.2? Can it put in 4? Whatever you get, set a variable like n. Try a do-while loop (it should be in the walkthrough.

Also think about the number of hashes and spaces for height say h and row say r.

Good luck!

You must log in to answer this question.

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