answersLogoWhite

0

You use a break statement to end execution of the enclosing iterator (loop) or switch statement. If omitted at the end of a case label, execution continues to the next case label, including the default case, until a jump statement is encountered (break, goto or return) or the switch statement falls from scope. Sometimes this can be desirable behaviour, thus the use of break is optional. A break statement is always optional at the end of the default case, or the last case label.

Its usage in loops is always optional, to allow a loop to end prematurely regardless of the conditional expression that controls the loop.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What the syntax of for loop in c?

for (<exp1>; <exp2>; <exp3>) <statement> exp1 and exp3 are optional; statement can be null-statement or block-statement. Correction: All expressions are optional. An infinite loop has no expressions: for(;;);


What is syntax in c plus plus for declaring a variable?

type variable {[optional array size]} {= optional initializer};


Which statement is not frequently used in C plus plus?

The goto statement.


What is the purpose of break statement in c?

The break statement exits control of the innermost for, while or do-while loop, or switch statement.


What is the deffernce of the switch statement and the if statement in c plus plus?

If statement is single selection statement,whereas the switch statement is multiple selective.


What is break in c?

The break statement is used to exit a loop or switch-case.


How are break points set using c plus plus?

Break points are a feature of the debugger and is implementation specific. For instance, in Visual C++, you place the cursor at the line where you want the breakpoint to be and hit the F9 key to toggle it on and off. When enabled, you can set the properties of the breakpoint, such as what condition(s) must be true in order for the program to break at that point.


What is the purpose of Continue and break statement in C?

The break statement is frequently used to terminate the processing of a particular case within a switch statement. Lack of an enclosing iterative or switch statement generates an error.Within nested statements, the break statement terminates only the do, for, switch, or whilestatement that immediately encloses it. You can use a returnor goto statement to transfer control elsewhere out of the nested structure.This example illustrates the break statement:#include int main() { char c; for(;;) { printf_s( "\nPress any key, Q to quit: " ); // Convert to character value scanf_s("%c", &c); if (c == 'Q') break; } } // Loop exits only when 'Q' is pressed


Basic control structure available in c plus plus?

The basic control structure in C++ is the if statement.


What is the format of if statement in c plus plus?

Syntax:if (expression)statement;[elsestatement;]The expression must evaluate to a boolean value, where zero is false and all non-zero values are true. The statement (including the optional else statement) may be simple or compound, and may include a nested if statement. When the expression evaluates true, the first statement is invoked. If an else statement is provided, it is only executed when the expression evaluates false. After the appropriate statement is invoked, execution passes to the statement that immediately follows the entire if statement.


What advantage does Java's break statement have over C's break statement?

They do the same thing, but only the former can be used in a Java program.


A c plus plus statement that invokes a function is known as?

...a function call.