A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

When running a for loop is there any way to make it restart the function. Kind of like a return command.

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Looks like your pastebin got deleted. Try using dpaste.com as it keeps stuff longer, and doesn't have the annoying ads.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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; } } }

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    'continue' should help

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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?

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    o ok what if your using loops within loops which will it return to?

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    to the inner one

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    o then that wouldn't have worked but thanks. continue may come in handy later tho.

  11. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    In your case I guess you could use a flag mechanism with a break or something like that, as per your requirement.

  12. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.