Functions are necessary for handling repetitive tasks, processing a complex procedure, or tackling specific programming issues. To create a function in your code you must either place it in a specific location or supply a function prototype that introduces the function to the compiler, ensuring that the function is used properly.
- [Instructor] C offers no rules … about when a function is necessary or required. … It's best however, to add a function, … when you use the same statements … or perform the same process repeatedly in the code. … For example, you could write a function to prompt for input … that's prompted for several times. … You could also build a function to handle a specific task. … For example, a complex calculation, … doing so can help make your code more readable … and you can write a function whenever the mood hits you. … Again, there are no rules. … When you code a function, … you set a data type for the value returned, … or you use void, if no value is returned. … Then comes the function, name. … Functions are named just like variables … and the same rules apply. … In the parentheses, you set arguments. … Functions with no argument list void in the parentheses. … A set of curly braces encloses the functions statements. … Functions that have a return value … must have a return statement … to pass the value back to the caller. …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.