

4 Functions from the C Standard Library.

We could write it like this (assuming we don't have a predefined function for absolute value in any library):

You will need to compute the absolute value of the whole numbers x and y.
#Stats xsort method code
Understanding what is happening inside your computer at the lowest levels can be confusing at first, but will eventually become very intuitive as you develop your C programming skills.įor now, it's enough to know that a function and its associated block of code is often executed (called) several times, from several different places, during a single execution of a program.Īs a basic example, suppose you are writing a program that calculates the distance of a given (x,y) point to the x-axis and to the y-axis. If this doesn't make immediate sense to you, don't worry. After the function's instructions finish executing, the function can return a value and code execution will resume with the instruction that immediately follows the initial call to the function. The instructions associated with a function are frequently referred to as a block of code. In the source code, this memory address is usually given a descriptive name which programmers can use to call the function and execute the instructions that begin at the function's starting address. Functions are a fundamental feature of any high level programming language and make it possible to tackle large, complicated tasks by breaking tasks into smaller, more manageable pieces of code.Īt a lower level, a function is nothing more than a memory address where the instructions associated with a function reside in your computer's memory. Note that other programming languages may distinguish between a "function", "subroutine", "subprogram", "procedure", or "method" - in C, these are all functions.

In C programming, all executable code resides within a function.
