answersLogoWhite

0

It's the same as the purpose of a function, procedure, method, ... in other programming languages. The basic idea is that you have a certain calculation or processing that has to be repeated over and over again (perhaps with slight variations), so it is programmed in a single place, where it can be invoked from different parts of the program. For example, if you need to calculate a square root, you program this in a single place (a function); you don't repeat all the complicated calculations everywhere you need to calculate a square root. In this example, since it is a fairly common requirement, it is already programmed in most programming languages; but you can also create your own functions for more customized calculations or processing.

User Avatar

Wiki User

10y ago

What else can I help you with?