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?)
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?)
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.
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! :)
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!