CS105

What is a function?       Why do you need a function?

Scope of the function.   Examples of functions.     



Scope of a Function

The simplest kind of functions in C++ are those which do not require any information to be sent to them from the main function and do not send anything back to the main function. In this case all you have to do to create a function is give it a name and specify its definition like this:

void function_name( void )
{
// details of what the function does
}

The function name can be anything you like but usually it indicates to the reader what the function does. The void inside the parentheses indicates that no information is delivered to the function when it is called and the void before the name indicates that the function returns nothing to the main function - this will change later.

 

       What is a function?       Why do you need a function?

Scope of the function.   Examples of functions.