Answer in brief
Functions communicate by receiving argument values, returning a value and, when appropriate, accessing objects through pointers or shared declarations.
Actual arguments
An argument is an expression written in the call. In add(x, 5), the value of x and the value 5 are supplied. An argument can be a constant, variable or a more complex expression, provided its type and use are suitable for the function.
Formal parameters
Parameters are declared in the function definition. In int add(int a, int b), a and b are separate local parameter objects for each call. Their names need not be the same as the caller’s variable names. C passes values: changes to a or b alone do not change the caller’s ordinary integer variables.
Return communication
return expression; supplies one result value to the caller for a non-void function. The caller can assign that result to a variable, print it or use it in another expression. The return type describes the kind of result.
Example trace
If x contains 4, add(x, 5) supplies 4 and 5. The parameter objects receive those values. The function returns 9. If the caller writes result = add(x, 5);, result becomes 9 while x remains 4.
Important points
Use a visible prototype and compatible types. C does not generally specify the order in which different argument expressions are evaluated. Avoid calls that update the same variable in conflicting argument expressions. Prefer clear, independent arguments. Pointer-based output is introduced separately; the pointer value is still passed by value.
Related exam questions
Related questions in the function declarations category from the supplied papers. The marks below are the printed allocations, including any combined subquestion.
View this category in the exam question bank →