It should work for the next numbers also
Why this isn't working?
What output are you expecting?
Since you have created and infinite loop…there must be a break statement within in else this will lead to an infinite iteration which will give error.
I have used the continue loop there, So I want it should check after 21 too and then give the output too.
Continue will have no effect there. As without break, your loop will run infinitely and your code will always give error. It will not produce any output.
Check now with break statement
But What can I do to check the numbers after 21?
Take input and store all the numbers before in an array. After that run a loop to iterate the array and check for the condition. If condition satisfies then print the result. No need to break the loop in that case.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.