课程: Complete Guide to C Programming Foundations
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Creating recursive functions
- [Instructor] A recursive function is one that calls itself. It's like a picture within the same picture or a door that opens into a room with a door that opens into the same room. Yes, this concept is mind-boggling, but recursion has useful purposes. In this code, function recurse calls itself. The problem with recursion, however, is that the function keeps calling itself with no end possible. This condition is a serious concern with recursion. Like a loop, you need a terminating condition for the recursive function. Otherwise, all sorts of bad things can happen, primarily, (laughing) the program crashes. Let's run to find out. Oops. In this configuration, the function has called itself recursively 261,939 times, and a really bad error has occurred. This code is not a successful example of recursion. But it can be fixed. A successful recursion function has an exit condition, where the function returns to itself. (computer keys clicking) The if statement provides the exit condition…
内容
-
-
-
-
-
-
-
Understanding functions3 分钟 11 秒
-
(已锁定)
Creating a function4 分钟 52 秒
-
(已锁定)
Challenge: Writing a function39 秒
-
(已锁定)
Solution: Writing a function1 分钟 49 秒
-
(已锁定)
Returning a value from a function2 分钟 23 秒
-
(已锁定)
Challenge: Returning a value53 秒
-
(已锁定)
Solution: Returning a value2 分钟
-
(已锁定)
Passing arguments to a function2 分钟 22 秒
-
(已锁定)
Challenge: Passing values41 秒
-
(已锁定)
Solution: Passing values1 分钟 50 秒
-
(已锁定)
Using the main() function's arguments2 分钟 13 秒
-
(已锁定)
Retaining values in a function2 分钟 34 秒
-
(已锁定)
Creating recursive functions3 分钟 44 秒
-
(已锁定)
Chapter challenge: Write the functions1 分钟 14 秒
-
(已锁定)
Chapter solution: Write the functions2 分钟 15 秒
-
-
-
-
-
-
-