function

15 Results

Dictionary

function

In programming, a self-contained software routine that performs a task. Functions can do a large amount of processing or as little as adding two numbers and deriving a result. Values are passed...

Dictionary

Definition: function

In programming, a self-contained software routine that performs a task. Functions can do a large amount of processing or as little as adding two numbers and deriving a result. Values are passed to the function, and values may be returned. Or, the function may just perform the operation and not return a resulting value. The concept of a function within a program is that, once written, it can be used over and over again without the programmer having to duplicate the same lines of code in the program each time that same processing is desired.

Standard and Programmer-Defined
Programming languages provide a set of standard functions as well as allow programmers to define their own functions. For example, the C and C++ programming languages are built entirely of functions and always contain a "main" function.

The Application Programming Interface (API)
Functions in one program can also be called for by other programs and shared. For example, operating systems can contain more than a thousand functions to display data, print, read and write disks and perform a myriad of tasks. Programmers write their applications to interact with the OS using these functions. This list of functions is called the "application programming interface" (API).

Function Calls
Functions are activated by placing a "function call" statement in the program. The function call often includes values (parameters) that are passed to the function. When called, the function performs the operation and returns control to the instruction following the call. The function may return a value or not. Writing a program in a language such as C/C++ involves calling language functions, one's own functions and operating system functions (APIs). There is a whole lot of function calling. See function prototype, API and interface.

A Function Call Example: Open and Read
The example below shows two very simplified API functions to open and read a file.

The OPEN function is called to read the file "budget.txt," and the function returns a value in the variable HANDLE. If the file was opened successfully, HANDLE might contain a positive number, but if not, a negative one. The value in HANDLE is then passed to the READ function to read so many bytes (LENGTH) of the file into a memory area called INPUTBUFFER. The OPEN function returns the number of bytes read in the SIZE variable.

 handle = open("budget.txt");
 size = read(handle, InputBuffer, length);





Sponsored White Papers, Webcasts & Resources

  • Get Your Free Trial of Diskeeper 2011 Professional

    Give your business desktops and laptops a boost. Diskeeper 2011 Professional prevents the majority of fragmentation before it can happen and brings data flow up to peak speed for the best possible...

  • The common error of overloading mobile apps with features

    The crowded app stores drive developers to put lots of features in their mobile apps. This is a mistake, as simple, focused apps rise to the top.

    Blog posts | November 25, 2011 12:07pm PST

  • 'Highly critical' flaws haunt phpMyAdmin

    Developers of the open-source phpMyAdmin have released a new version to patch several "highly critical" vulnerabilities that can be used to compromise a vulnerable system.

    Blog posts | July 5, 2011 8:05am PDT

  • Architectural layers

    Abstracting IT functions and services into service layers is a great idea, but don't over do it, as Geek & Poke's Oliver Widder reminds us.... [caption id="" align="alignleft" width="500"...

    Blog posts | March 6, 2011 6:47am PST

  • Cellphones are becoming useless at their primary function - Voice and text

    I've noticed a very disturbing trend. It's that cellphones are becoming useless at their primary function - which is voice and text.

    Blog posts | September 30, 2010 11:57am PDT

  • ThinPrint addressing the boring but absolutely necessary

    I spoke with ThinPrint CEO, Henning Volkmer, about a rather boring, but absolutely necessary function in a computing environment. Printing is one of those functions that is taken for granted...

    Blog posts | May 28, 2010 3:06am PDT

  • Are appliances the answer?

    Are appliances the answer? That depends entirely on the question of course. I've spoken with a number of suppliers who have "encapsulated" a function and are selling it as an appliance server....

    Blog posts | January 13, 2009 12:59am PST

  • The case for Scala

    Programming languages are like screwdrivers for developers. One size does not fit all, so good programmers keep several in their tool belt. The problem is, new languages are coming out all the...

    Blog posts | November 24, 2008 8:04am PST

  • Flower robots for your home

    Flower robots are not new and some have already been developed in the U.S. Now, South Korean researchers have created a robotic plant which acts like real ones. This robot has humidifying,...

    Blog posts | October 16, 2008 9:59am PDT

  • What is virtualization?

    As I'm preparing to leave VMworld, I find myself thinking about a question I heard at the event. That question is "what is virtualization?". Living in the virtual world a great deal of the time,...

    Blog posts | September 18, 2008 3:00am PDT

  • Yo Philly: iSepta perfect for Philly iPhone users

    Having spent almost 20 years in Philadelphia iSepta is one application that I can relate to. SEPTA, for the uninitiated, is the South Eastern Pennsylvania Transportation Authority. SEPTA runs...

    Blog posts | May 20, 2008 10:25am PDT

  • Tideway Systems Simplifies Mapping Application Dependencies

    I had the delightful opportunity to speak with Richard Muirhead, Tideway Systems' Founder and CEO, about the launch of the newest release of Tideway Foundation. The company is focused on making...

    Blog posts | April 28, 2008 3:00am PDT

  • In the 'it's a feature' department: Caps Lock keys

    If you've noticed a change in the behavior of your Caps Lock key on new Apple machines, that may be the sign of a feature, not a bug.

    Blog posts | March 24, 2008 11:39am PDT

  • QuickOffice Premier 4.5 is essential in turning your S60 device into a multimedia computer

    When you buy a Nseries or one of the various other supported Nokia devices found around the world then you will find that the QuickOffice software is preinstalled as the Office document. However,...

    Blog posts | December 8, 2007 9:22pm PST

  • 'Storm worm' exploits YouTube

    Spammers may have changed tactics, targeting a familiar Web site rather than PCs for the purpose of spreading the trojan.

    News items | October 10, 2007 6:09am PDT

  • Using lambda functions

    This five minute video explores how to use lambda functions in concert with Threaded Building Blocks to make parallel code more readable.

    Videos | January 1, 2006 12:00am PST

Additional Results

ie8 fix

The best of ZDNet, delivered

ZDNet Newsletters

Get the best of ZDNet delivered straight to your inbox

Facebook Activity

ie8 fix