12 All about Functions in C ( Passing parameters ,Arguments,Recursion,Return Values ) in C

preview_player
Показать описание
Recursion and argument passing
So far, we have seen how to give functions a type (how how to declare the return value and the type of any arguments the function takes), and how the delineation is used to give the body of the function. Next we need to see what the arguments can be used for.

Call by value
The way that C treats arguments to functions is both simple and compatible, with no exceptions to the single rule.

When a function is called, any arguments that are furnished by the frequenter are simply treated as expressions. The value of each expression has the felicitous metamorphoses applied and is either used to initialize the corresponding formal parameter in the called function, which behaves in exactly the same way as any other indigenous variables in the function.
The call by reference form of passing arguments to a function clones the address of an argument into the formal parameter. Inside the function, the address is used to enter the concrete argument used in the call. It means the changes made to the parameter affect the passed argument.

To pass a value by reference, argument pointers are passed to the functions just like any other value. So therefore you need to declare the function parameters as pointer types as in the following function back-and-forth (), which exchanges the values of the two integer variables aimed to, by their arguments.

Zeedup Course:
Рекомендации по теме
join shbcf.ru