Functions

Functions

 

A function is a block of code that has a name and a block of statements that are executed when the function is called. To perform repetitive tasks, Custom functions are used. Functions are declared by first declaring the function type followed by function name and in paranthesis any parameters being passed to function.

Syntax:

type function_name(parameters)
{
statements;
}

{} curly braces

These curly braces are used to define beginning and end of a function block and statements. An opening curly brace { must always be followed by a closing curly brace }.

; semicolon

A semicolon must be used to end a statement and separate elements of the program.

/*…….*/ block comments

Block comments or multi line comments are areas of text ignored by the program and are generally used for large text descriptions of codes and  to write comments to help understand the programmer and users.

// line comments

Single line comments begin with // and end with the next line of code. These are also ignored by the program and does not occupy any memory space.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s