09.10.2014 Views

download pascal tutorial (pdf - Tutorials Point

download pascal tutorial (pdf - Tutorials Point

download pascal tutorial (pdf - Tutorials Point

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER<br />

11<br />

Functions<br />

This section shows the general form of functions used in Pascal:<br />

Subprograms<br />

A<br />

subprogram is a program unit/module that performs a particular task. These<br />

subprograms are combined to form larger programs. This is basically called the 'Modular<br />

design.' A subprogram can be invoked by a subprogram/program, which is called the<br />

calling program.<br />

Pascal provides two kinds of subprograms:<br />

<br />

<br />

Functions: these subprograms return a single value.<br />

Procedures: these subprograms do not return a value directly.<br />

Functions<br />

A function is a group of statements that together perform a task. Every Pascal program<br />

has at least one function, which is the program itself, and all the most trivial programs can<br />

define additional functions.<br />

A function declaration tells the compiler about a function's name, return type, and<br />

parameters. A function definition provides the actual body of the function.<br />

Pascal standard library provides numerous built-in functions that your program can call.<br />

For example, function AppendStr() appends two strings, function New() dynamically<br />

allocates memory to variables and many more functions.<br />

TUTORIALS POINT<br />

Simply Easy Learning Page 58

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!