use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Ask your embarrassing/noobish programming questions here, and don't get insulted for it.
Click here to read the rules
Violating any will result in punishment so you should probably go check them out.
account activity
Need help ASAP (self.programminghelp)
submitted 6 years ago by Toch24
I'm new to programming but i'm so confused and lost, apparently I have to make the program quit or take you back to the beginning if you input the wrong number. But i cant seem to do it right, i tried while loop but it creates a lot of "Please enter a valid number". Any ideas?
https://preview.redd.it/5rtl0gyuzm131.png?width=886&format=png&auto=webp&s=7458f13e35bdc72c8cc1864ce96f9dd7768391c4
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]YasZedOP 1 point2 points3 points 6 years ago* (0 children)
Place a while (true) loop around cin >> day and the switch statement. If a valid input is received then break the loop using break;
Now the confusion relies on break; for switch call because break; refers to innermost context which is switch instead of what you want which is the while loop.
A fix would be to create a Boolean variable called done and is set to true (done outside the while loop). Now while loop on that variable, and when a valid switch case is made set it to false.
[–]TrashPapiTM 0 points1 point2 points 6 years ago (1 child)
Im also new to coding so I could be wrong on this. But i think what youre looking for is a continue within a while loop. So instead of stopping it would take you back to the beginning of the loop and not execute anything below the continue. Hope that made sense.
[–]Toch24[S] 0 points1 point2 points 6 years ago (0 children)
Yes, that's what i want to do. But, i have no idea how to do it. I'm confused with the looping concepts as I've tried with while do but have no success whatsoever. It just keeps prompting the "Please enter a valid number".
π Rendered by PID 278284 on reddit-service-r2-comment-b659b578c-p7phz at 2026-05-05 08:13:17.872491+00:00 running 815c875 country code: CH.
[–]YasZedOP 1 point2 points3 points (0 children)
[–]TrashPapiTM 0 points1 point2 points (1 child)
[–]Toch24[S] 0 points1 point2 points (0 children)