When running a for loop is there any way to make it restart the function. Kind of like a return command.
I meant to say restart the loop. Here is the code I need it for i need it to stop because i only need one solution for each. http://pastebin.com/vA7HeUMi. It is giving me multiple solutions for each. By the way this is Pset2 problem 3
Looks like your pastebin got deleted. Try using dpaste.com as it keeps stuff longer, and doesn't have the annoying ads.
you can try making it recalling the function with a base case and return after that example void main() { for(int i = 0; ;i ++) { printf("waha"); if(i == 10) { main(); return; } } }
ok i used dpaste this time. http://dpaste.com/hold/525841/ . I actually deleted the last post on purpose though because it had an infinite loop that i didn't notice. Now I just need it to only give me one answer for each instead of every possible solution. After that I will put a counter in to Keep track of how many in a row it gets.
'continue' should help
I finished my code already what i did is made two separate functions and called one function within another that way I could use return. Have we learned the continue function in this course yet and what does it do?
I'm not really sure about the course, but the continue sends the flow of control to the first line of the loop from anywhere within the loop.
o ok what if your using loops within loops which will it return to?
to the inner one
o then that wouldn't have worked but thanks. continue may come in handy later tho.
In your case I guess you could use a flag mechanism with a break or something like that, as per your requirement.
Join our real-time social learning platform and learn together with your friends!