Chapter 11

Functions

In C, a function is an independent block of code that performs a specific task when called, and it may return a value to the calling program. Each function is essentially a small program, with its own variables and statements. A program is divided into smaller parts using functions, making it easier to understand, modify, and control. Another benefit of functions is that they are reusable. For example, the printf() and scanf() functions can be used in every C program.

Up to this point, we’ve written just one function, the main(). In this chapter, you’ll learn how to declare and use your own function within your programs.

Function Declaration

A function declaration or function prototype specifies the name of the function, ...

Get C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.