Function Declaration

By: Jesse Miller

C programming functions contain pieces of code to be executed whenever the function is called in a program. C programs contain a number of custom functions which can be called as required during the execution of the program.

Functions contain a group of statements which are executed whenever the function is called. Once their statements have been executed program flow resumes at the point the function was called. This modularity is very useful in programming to separate set routines so they can be used repeatedly.

To introduce a custom function into a program it must first be declared, in a similar manner that variables must be declared before they can be used. Function declarations should be added to the program code before the main () function.

Like the main () function, custom function can return a value. The data type of this value must be included in the function declaration. If the function is to return no value its return data type should be declared with the void keyword. The function should be named following the same naming conventions used for variable names.

The function declaration is more correctly called the function prototype and simply informs the compiler about the function. The actual function definition, which includes the statements to be executed, appears after the main () function. The custom function then be called upon to execute its statements from within the main () function, as required.

If a custom function returns a value this value can be assigned to a variable of the appropriate data type, or simply displayed as output using the appropriate format specifier. The function prototype also sometimes referred to as the function header.

Custom functions can call other custom functions, just as readily as they can call standard library functions like printf (). Multiple functions can called from other functions that is called function can call other function.

Quick Note: Taking the Nonsense out of looking for the right spyware remover

If you really want to take the work out of looking for that right Spyware Protection from a go to the Internet and get a or a Free
Download, In order to prevent your vital information from being ripped from your computer get your Remover Today.

Functions that call themselves are known as `recursive` functions. As with a loop the function must modify a tested condition to avoid locking the program. When developing larger programs some thought should be given to program structure. Maintaining the entire program code in a single file can become unwieldy as the program grows. In order to simplify the program structure a custom header file can be created to contain functions which may be used repeatedly. This should be named with a `.h` file extension, like the standard header.

Top Searches on
Computers
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 

» More on Computers