« Back to Main Page

Explaining Functions

From Bold Idea Knowledgebase

A function is a group of code that you can re-use elsewhere in your program. As coders, we often want to be able to re-execute blocks of code when we are writing programs, without having to re-write the block of code entirely. Functions give us a way of grouping code together and giving it a name, so that we can call it by that name later. To create a function, we must first declare it and give it a name, and then follow it by a function definition. We could put any code inside that function – one statement, multiple statements – depends on what we want to do.

What is it?

A function is a group of code that you can re-use elsewhere in your program.

The function definition is the actual code of the function, while the function call is used when we tell the functions to run.

A procedure is just another way of saying function.