Wednesday 13 February 2013

Parameter of a Function in C Programming



The term 'parameter' has been introduced earlier. To review, consider the following printf() statement:

printf("%d", value);

The printf() function expects two pieces of information:

1. The format(s) in which data is to be printed.
2. The variable(s) whose value(s) is/are to be printed in the specified format(s).

These are the parameters of the function printf().

Thus, parameter(s) of a function is/are the data that the function must receive when called or invoked from another function.

Not all standard functions require a parameter. An example is getchar(). Similarly, user-defined functions may or may not have parameters.

Consider the following examples:

main()
{
disp_head();
}

disp_head()
{
printf("Employee report");
}

The function disp_head() in program does not expect any data when invoked.

0 comments:

Post a Comment

Powered by Blogger.