...

/

Simple User-defined Functions

Simple User-defined Functions

Learn to divide a program into functions or subprograms in C++.

Function

We can divide a program into procedural components or modules called functions in C++. We are already familiar with a function, main(). Functions can be reused in a programming technique called the modular or procedural approach, also known as the divide and conquer approach. We should always try to design functions that can be copied and reused in other programs too.

Press + to interact

Broadly, there are two types of functions, which we’ll explore in the following sections.

Structure of a function

The following slides illustrate various parts of a function definition:

A function name can only contain ...