I have a lot of if statements in while loop, program has to print error messages according to conditions, but if there are more than one error it has to be only one of them.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question isn’t very detailed so it’s a little hard to tell what exactly do you want.
If you want the while loop to go to the next iteration after any error has fired, you should use the
continuestatement:If nothing else than these
ifs is inside the loop, and the conditions are integer values, you should consider usingswitchinstead:If you want to completely restart the cycle… well this is a little harder. Since you have a
whileloop, you can just set the condition to it’s starting value. For example, if you have a loop like this:then you can “reset” it like this:
However, you should be really careful with this, it’s easy to get an infinite loop accidentally.