课程: Complete Guide to C Programming Foundations
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Exploring the possibilities
- [Instructor] The if keywords companion is the else keyword. Combined, you use if and else in your code to create blocks of either/or decisions. For example, in this code, input is obtained from the user. The if statement at line 11 tests to see whether the value of variable A is greater than the value of variable B. If true, the statement belonging to if is executed. Otherwise, the else statement is executed. I'll try a few values, 10 and 20, and 20 is greater than 10, eight is greater than negative one, and now I'm going to try the same value. Well, the program didn't error, it just did what you told it to do. In the code, the else statement catches all conditions where A is greater than B is false, including when A is equal to B. To address this situation, we can modify line 13 to better reflect this result. Change it into an else/if statement. B is greater than A. This construction is a combination of else and if, and it represents a second decision. When this condition is true…
内容
-
-
-
-
-
-
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 秒
-
-
-
-
-
-
-
-