- A function call is very important in programming.
- When we need to call a function, it is called inside a program.
- A function which is being called by the parent functions is known as called functions
- Function which is being called is known as calling function.
- A function is called by the program whenever it is needed.
- Functions are called by its name in the main program.
- We can pass parameters to the functions that are being called in the main function.

Syntax
[pastacode lang=”c” manual=”Add(a%2C%20b)%20%2F%2F%20a%20and%20b%20are%20the%20parameters%20″ message=”” highlight=”” provider=”manual”/]Calling a function in C program
Add.c
[pastacode lang=”c” manual=”%23include%20%3Cstdio.h%3E%20%20%0Aint%20add(int%20a%2C%20int%20b)%3B%20%20%20%0Avoid%20main()%20%20%0A%7B%20%20%0A%20%20%0Aint%20sum%3B%20%20%0Aint%20a%2C%20b%3B%20%20%0Aprintf(%22%20Enter%20the%20first%20and%20second%20number%20%5Cn%22)%3B%20%20%0Ascanf(%22%25d%20%25d%22%2C%20%26a%2C%20%26b)%3B%20%20%0Asum%20%3D%20add(a%2C%20b)%3B%20%2F%2F%20call%20add()%20function%20%20%0Aprintf(%20%22The%20sum%20of%20the%20two%20number%20is%20%25d%22%2C%20sum)%3B%20%20%0A%7D%20%20%0Aint%20add(int%20n1%2C%20int%20n2)%20%2F%2F%20pass%20n1%20and%20n2%20parameter%20%20%0A%7B%20%20%0Aint%20c%3B%20%20%0Ac%20%3D%20n1%20%2B%20n2%3B%20%20%0Areturn%20c%3B%20%20%0A%7D%20%20%0A” message=”” highlight=”” provider=”manual”/]Output

Call by value
- When an single or multiple values of an argument are copied into formal parameters of a function, this type of functions is known as Call By Value.
- It does not change the value of the function`s actual parameter.
Call by Value in C programming
Call_Value.c
[pastacode lang=”c” manual=”%23include%20%3Cstdio.h%3E%20%20%0Aint%20main()%20%20%0A%7B%20%20%0Aint%20x%20%3D%2010%2C%20y%20%3D%2020%3B%20%20%0Aprintf%20(%22%20x%20%3D%20%25d%2C%20y%20%3D%20%25d%20from%20main%20before%20calling%20the%20function%22%2C%20x%2C%20y)%3B%20%20%0ACallValue(x%2C%20y)%3B%20%20%0Aprintf(%20%22%5Cn%20x%20%3D%20%25d%2C%20y%20%3D%20%25d%20from%20main%20after%20calling%20the%20function%22%2C%20x%2C%20y)%3B%20%20%0A%7D%20%20%0Aint%20CallValue(%20int%20x%2C%20int%20y)%20%20%0A%7B%20%20%0Ax%20%3D%20x%20%2B%205%3B%20%20%0Ay%20%3D%20y%20%2B%205%3B%20%20%0Aprintf%20(%22%20%5Cnx%20%3D%20%25d%2C%20y%20%3D%20%25d%20from%20modular%20function%22%2C%20x%2C%20y)%3B%20%20%0A%7D%20%20%20%0A” message=”” highlight=”” provider=”manual”/]Output

Call By Reference
- As name suggests call by reference is a method, where the address of the actual argument is copied into the function call’s formal parameter.
- This type of method is known as Call by Reference.
- If we make some changes in the formal parameters, it shows the effect in the value of the actual parameter.
Call by Reference in C programming
Call_Ref.c
[pastacode lang=”c” manual=”%23include%20%3Cstdio.h%3E%20%20%0Aint%20main()%20%20%0A%7B%20%20%0Aint%20x%20%3D%2010%2C%20y%20%3D%2020%3B%20%20%0Aprintf%20(%22%20x%20%3D%20%25d%2C%20y%20%3D%20%25d%20from%20main%20before%20calling%20the%20function%22%2C%20x%2C%20y)%3B%20%20%0ACallValue%20(%26x%2C%20%26y)%3B%20%20%0Aprintf(%20%22%5Cn%20x%20%3D%20%25d%2C%20y%20%3D%20%25d%20from%20main%20after%20calling%20the%20function%22%2C%20x%2C%20y)%3B%20%20%0A%7D%20%20%0Aint%20CallRef(%20int%20*a%2C%20int%20*b)%20%20%0A%7B%20%20%0A*a%20%3D%20*a%20%2B%205%3B%20%20%0A*b%20%3D%20*b%20%2B%205%3B%20%20%0Aprintf%20(%22%20%5Cnx%20%3D%20%25d%2C%20y%20%3D%20%25d%20from%20modular%20function%22%2C%20*a%2C%20*b)%3B%20%20%0A%7D%20%20%0A” message=”” highlight=”” provider=”manual”/]Output

