calling function.
Just as variables are declared, similarly functions needs to be declared as follows:
(arguments);
This is essentially a
function prototype.
If you are working in C on a UNIX platform, it may not
be necessary to write the prototype first, but if you are running your program with a C++ compiler, it
is necessary. Every C program can be run on a C++ compiler, too, as C is subset of C++.
For example,
fact(int n);
Here, ‘n’ is an actual argument and there is no return value in this function call. It ends with a
semicolon. On the other hand, consider
result = fact(int n);
This function call will return some value in the ‘result’ variable.
We can even write the following:
fact( );
This means that the function has nothing to return now and has no arguments.
The return Statement (in Functions)
Do'stlaringiz bilan baham: |