5

I am completely stuck. I'm not quite sure why I don't understand how to do this.

I don't understand the hash tag and spaces thing. I have read so many explanations of it on this website, but none of them make sense to me. I get that there are patterns, and I see the pattern, but I do not understand what to do with that pattern.

I also don't quite understand how I get the integer. I get I am asking the user, but how do you make it so they can only ask the number you want or lower? (In this case 23 or lower that is positive)

Any help is very much appreciated.

  • Duplicated: cs50.stackexchange.com/questions/1039/… – Kareem Jun 28 '14 at 7:58
  • Also, if you've watched the lectures, (optional) the walkthroughs, (optional) the shorts and (optional) the section carefully, you'd probably get some sort of an idea about how you can get an int from the user! – Kareem Jun 28 '14 at 8:00
  • I get how to get an int, just not with specifics. – user1549 Jun 30 '14 at 5:48
6

You are validating the input after they enter it.

So your program asks for input using GetInt(), which it sounds like you have figured out.

and then you write a piece of code (a loop might be pretty good for this) that says something to the effect of: If the value isn't within this range that I specify (perhaps greater than or less than but how you implement is up to you), prompt them again to enter a valid integer

This might help a little: look at the "comparison operators" table

| improve this answer | |
  • This actually helped a lot. Thank you! – user1549 Jul 2 '14 at 5:39
1

Try to understand the pattern for the "#" and " " (spaces). You can have a loop to iterate through the lines and some other loops to get the # and spaces. Do not lost in nested loops. Think how you can achieve the spaces and # in the same line with loops.

And for getting the integer, I think you should take a look into the walkthroughs and shorts of the week. Its very simple to validate user inputs using conditions. Don't get lost, stay there and try to figure out the process.

Hope this will help you.

| improve this answer | |
1

Regarding making sure that user insert the right integer,

  1. After asking the user to type, and you will read it by

    variable = GetInt()
    
  2. You have to iterate variable times.

  3. You will begin a nested loop to print the pyramid.

Hope that help you

Good luck

| improve this answer | |
0

You should post your pseudo-code and also watch the shorts again. Also try looking at an actualy ascii table and see what patterns you notice

| improve this answer | |

You must log in to answer this question.

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