课程: Complete Guide to C Programming Foundations

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Challenge: Returning a value

Challenge: Returning a value

(upbeat music) - [Narrator] Take a look at this code, provided in the exercise files. Anything stick out at you? What I see are a lot of repetitive statements. To me, such a condition begs for a function. Your challenge is to examine the code in the exercise file to see where you can create a function. How can you make the code more efficient and readable? Write the function. As a hint, I call mine roll. The function you create returns a value, which is used inside the main function. This process is typical for most programmers, where you spy a repetitive chunk of code that probably would fit better inside a function. Find that code, write that function. This challenge should take you about 10 minutes to complete.

内容