From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Chapter challenge: Write the functions - C Tutorial
From the course: Complete Guide to C Programming Foundations
Chapter challenge: Write the functions
(bright music) - [Instructor] Here's the setup for this chapter's challenge. You see a prompt for two values, input the values, then a series of functions appear which don't appear in the code. They're not written yet, add, subtract, multiply, and divide. Your task is to code these functions, all of which accept values, one of which returns values. Create the add function. It adds two integer arguments passed. It outputs this string assuming that the values are three and eight, and this function returns no values. Similarly, code the subtract and multiply functions. Their output is similar to the add function. Here are some examples of that output. Finally, code the divide function, which is different from the other three. This function accepts two integer values, but it does not output a string. Instead, it returns the result of the first value divided by the second. Use the challenge source code to clue you in to how this function is different if you need some hints. This exercise…
Contents
-
-
-
-
-
-
-
Understanding functions3m 11s
-
(Locked)
Creating a function4m 52s
-
(Locked)
Challenge: Writing a function39s
-
(Locked)
Solution: Writing a function1m 49s
-
(Locked)
Returning a value from a function2m 23s
-
(Locked)
Challenge: Returning a value53s
-
(Locked)
Solution: Returning a value2m
-
(Locked)
Passing arguments to a function2m 22s
-
(Locked)
Challenge: Passing values41s
-
(Locked)
Solution: Passing values1m 50s
-
(Locked)
Using the main() function's arguments2m 13s
-
(Locked)
Retaining values in a function2m 34s
-
(Locked)
Creating recursive functions3m 44s
-
(Locked)
Chapter challenge: Write the functions1m 14s
-
(Locked)
Chapter solution: Write the functions2m 15s
-
-
-
-
-
-
-