0
1.1kviews
What is a Function?
1 Answer
1
5views

A function can be called by simply using the function name in the statement.

Eg:

main() 
{ 
int p; 
p = mul(10,5); 
printf(ā€œ%d \nā€, p); 
}

When the compiler executes a function call, the control is transferred to the function mul(x,y).The function is then executed line by line as described and the value is returned, when a return statement is encountered. This value is assigned to p.

Category of Function

A function may belong to one of the following categories.

1) Functions with no arguments and no return values.

2) Functions with arguments and no return values.

3) Functions with arguments and return values.

No Arguments and No Return Values

A function does not receive any data from the calling function. Similarly, it does not return any value.

Arguments but No Return Values

The nature of data communication between the calling function and the called function with arguments but no return values.

Arguments with Return Values

Here there is a two-way data communication between the calling and the called function.

Please log in to add an answer.