What are functions in C?
Earlier, for me, the function in C meant only a group of statements that is executed when it is called from some point of the program. And I thought the function in C is different from the functions that I learnt in mathematics.
C language has functions that performs a particular task and returns a value. These functions contain a set of instructions that performs various operations.
Mathematically, a function is a relation between a set of inputs and a value. It is a mapping from a domain to a co-domain. We can compare the functions in C also to such mappings. Here the domain is formed by the arguments passed to the functions. Those are the values on which the function is going to operate. The function performs a particular operation and then returns a value. That is the value to which the inputs are mapped. Thus for each value in the domain, there exists a return value.
This knowledge gives a wider understanding of what a function is and how it works apart from the normal definitions in the C language references.