Thursday, February 9, 2012

Your Complete News Guide to Latest Technologies and Trends

Your Complete News Guide to Latest Technologies and Trends

Looking Adeptly at Programming Function Examples

Posted by Admin On April - 6 - 2009

Before looking at the different examples of programming functions, it is best to understand the purpose and definition of function. A function is the means by which someone who uses a program can execute a code block which has two purposes: to finish a certain task and to return values. Although functions are expected to return a certain value, it is not always that values are returned.

A function is also considered as a procedure in some programming languages. On the other hand, functions are commonly known as any term that is being used in referring to names of code blocks. Take note that it is the C programming language which solely uses the keyword function. Functions accept restrictions, they also return values, and they are maintained on a separate location from the code of primary program. The C language uses main function as the point of entry to certain programs.

Functions can show up in a single or two locations. This is dependent on whether the function is single line or multi-line. Having a single line function means a value is returned after the performances of work (in a single line) while the multi-line function is broadened over different lines.

Perhaps, the most common example of a programming function is a mathematical function. Log and tan are examples of mathematical functions. The other two known functions are string functions and the date functions.

Simply defined, a programming function allows you to assign certain values where results can be calculated in a matter of seconds while saving yourself from the task of doing the computations manually.

On the declaration or calling of a function which has two or more parameters, the use of comma is needed to separate the different parameters. One function declaration could resemble this:

function print_two_strings($var1, $var2)
{
echo $var1;
echo “n”;
echo $var2;
return NULL;
}

For these functions to be called, a value must be assigned to the parameters, hence:

Function call:

Print two strings (

More Related Topics

  • No Related Post

Leave a Reply