Skip to content

Commit 81cb79b

Browse files
authored
Merge pull request #4910 from Omcsesz/fix/break-statement-documentation-fix
Break statement documentation fix
2 parents 23cea71 + e224147 commit 81cb79b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

docs/cpp/break-statement-cpp.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ title: "break Statement (C++)"
44
ms.date: "11/04/2016"
55
f1_keywords: ["break_cpp"]
66
helpviewer_keywords: ["break keyword [C++]"]
7-
ms.assetid: 63739928-8985-4b05-93ce-016322e6da3d
87
---
9-
# break Statement (C++)
8+
# `break` statement (C++)
109

1110
The **`break`** statement ends execution of the nearest enclosing loop or conditional statement in which it appears. Control passes to the statement that follows the end of the statement, if any.
1211

1312
## Syntax
1413

15-
```
14+
```cpp
1615
break;
1716
```
1817

1918
## Remarks
2019

21-
The **`break`** statement is used with the conditional [switch](../cpp/switch-statement-cpp.md) statement and with the [do](../cpp/do-while-statement-cpp.md), [for](../cpp/for-statement-cpp.md), and [while](../cpp/while-statement-cpp.md) loop statements.
20+
The **`break`** statement is used with the conditional [`switch`](../cpp/switch-statement-cpp.md) statement and with the [`do`](../cpp/do-while-statement-cpp.md), [`for`](../cpp/for-statement-cpp.md), and [`while`](../cpp/while-statement-cpp.md) loop statements.
2221

2322
In a **`switch`** statement, the **`break`** statement causes the program to execute the next statement outside the **`switch`** statement. Without a **`break`** statement, every statement from the matched **`case`** label to the end of the **`switch`** statement, including the **`default`** clause, is executed.
2423

@@ -58,7 +57,9 @@ int nums []{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
5857
```
5958

6059
```Output
61-
In each case:
60+
1
61+
2
62+
3
6263
1
6364
2
6465
3
@@ -93,8 +94,14 @@ int main() {
9394
```
9495

9596
```Output
96-
In each case:
97-
0123
97+
0
98+
1
99+
2
100+
3
101+
0
102+
1
103+
2
104+
3
98105
```
99106

100107
The following code shows how to use **`break`** in a switch statement. You must use **`break`** in every case if you want to handle each case separately; if you do not use **`break`**, the code execution falls through to the next case.

0 commit comments

Comments
 (0)