课程: Complete Guide to C Programming Foundations
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Breaking out of a loop
- [Instructor] A loop repeats its statements until the terminating condition is met or until a break statement is encountered. In this code, input from the user is requested. The loop repeats based on the value input or until the value of variable A reaches nine, run. I'm going to try a huge value like 300, but you see the loop only repeats 10 times. The IF statement at line 12 tests to see when the value of variable A is equal to nine. If so, its sole statement break is executed, the loop is broken, and execution continues outside the loops block. When used in a nested loop break halts only the loop it sits in here, you see nested for loops. At line 13 an if test is made, if variable column is equal to the letter E, the inner loop is broken run, and the table stops output at all rows after letter E, only the inner loop is affected. You can use break to avoid entangling your code in an endless loop. Here, the while loops condition is one, true. The loop has no exit condition except…
内容
-
-
-
-
-
-
Making a decision3 分钟 25 秒
-
(已锁定)
Exploring the possibilities2 分钟 53 秒
-
(已锁定)
Using the ternary operator3 分钟
-
Working with the switch-case structure4 分钟
-
(已锁定)
Challenge: Select an item28 秒
-
(已锁定)
Solution: Select an item1 分钟 45 秒
-
Creating a for loop3 分钟 36 秒
-
(已锁定)
Setting up a while loop2 分钟 58 秒
-
(已锁定)
Challenge: Repeat some text51 秒
-
(已锁定)
Solution: Repeat some text1 分钟 51 秒
-
(已锁定)
Nesting loops1 分钟 59 秒
-
(已锁定)
Breaking out of a loop3 分钟 16 秒
-
(已锁定)
Avoiding the goto keyword1 分钟 33 秒
-
(已锁定)
Chapter challenge: Interpreting commands2 分钟 26 秒
-
(已锁定)
Chapter solution: Interpreting commands3 分钟 55 秒
-
-
-
-
-
-
-
-