How does the 'return' statement affect the flow of control within a loop?

  • The 'return' statement exits the loop, returning control to the calling function or method.
  • The 'return' statement has no impact on the flow of control within a loop.
  • The 'return' statement skips the next iteration of the loop.
  • The 'return' statement terminates the entire program when used within a loop.
The 'return' statement is used to exit a function or method prematurely and return a value. When a 'return' statement is encountered within a loop, it immediately exits the loop and returns control to the calling function or method. This can be useful for ending a loop under certain conditions or returning a value from the loop.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *