What is the difference between break and continue in the context of a loop?
- break stops the loop, continue skips to the next iteration
- break skips to the next iteration, continue stops the loop
- Both have the same function
- Neither is used in loops
In a loop, the break statement is used to exit the loop prematurely, halting its execution entirely. On the other hand, the continue statement skips the remaining part of the current iteration and jumps to the next iteration.
Loading...
Related Quiz
- What is the primary purpose of encapsulation in object-oriented programming in C++?
- A C++ application is experiencing crashes due to memory corruption. During debugging, you notice that a function modifies the memory location of a pointer passed to it, affecting other parts of the application. Which concept might help prevent this issue in future implementations?
- When performing a bitwise AND operation with a number and 0, the result is always _______.
- Which bitwise operator is used to flip the bits (change 1s to 0s and vice versa) of a binary number?
- When a class contains a pointer to memory allocated in class, we should define a _______.