O'Reilly logo

C by Nikolaos D. Tselikas, George S. Tselikis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required