A function is a block of code that has a name, a return type and a list of arguments. Every C++ program has at least one function: main. Execution of a program always starts with main. The function main usually makes calls to other functions. In this lesson you will learn to write your own functions, and call them. One use for functions is to break a program into separate functions to improve the readability of a program and to create functions that can be used in other programs. Each function should have a clearly defined purpose. Each function should also have a comment to explain its purpose.

Please study the material at each of the links below.

  1. A function half
  2. Function prototypes
  3. A function to print area
  4. A function area with prototype
Like us on Facebook:

OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: May 18 2017 14:04:54.