___________ will immediately jump to the end of the current block of code

Options
- continue
- exit
- goto
- break


CORRECT ANSWER : break

Discussion Board
break-

The break statement terminates the loop immediately when it is encountered. This statement jump end of the current block.
Whenever it is encountered in switch-case block, the control comes out of the switch-case body.

Syntax:

break;

Sapna 02-24-2017 12:12 AM

Break statement

This is a BADLY WORDED question with no answer. The writer is confusing the term "code block" with an execution loop statement. The correct QUESTION should be: "What causes an enclosing for, range-for, while or do-while loop or switch statement to terminate?" (en.cppreference.com).

Break does not cause execution to jump to the end of the current (enclosing) block!! When the following code executes, the break statement terminates the while loop; it does not simply skip over code which follows it inside the containing conditional code block.

int i = 5;
while (i--) {
if (true) {
std::cout << "Before break" << std::endl;
break;
std::cout << "After break" << std::endl;
}
std::cout << "Next iteration" << std::endl;
}
std::cout << "End break test" << std::endl;


gds 06-15-2014 07:59 PM

Controls in C

- continue - forces the next iteration of the loop to occur, skipping any code in between.

- exit function calls all functions registered and terminates the program

- goto - this statement is used for altering the normal sequence of program execution. The control of the program is transferred to some other part of the program.

- break - break statement terminates the execution of the nearest enclosing.



Aparna 07-5-2013 06:30 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement