0 votes
in C Plus Plus by
Can a return statement be used within loops? How does it affect the loop execution?

1 Answer

0 votes
by

Yes, a return statement can be used within loops. When the return statement is encountered in a loop, it immediately terminates not just the loop but also the function execution and returns control to the calling function. The remaining iterations of the loop are skipped and any code following the loop or return statement within the same function will not be executed.

Related questions

0 votes
asked Dec 21, 2023 in C Plus Plus by GeorgeBell
0 votes
asked Dec 21, 2023 in C Plus Plus by GeorgeBell
...