 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you the difference between call by value and call by address available in C programming. Before starting, you can note my information, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app TechMS which is available on Google Play. Now, first I am going to implement call by value so that we can understand how call by value works in C programming. So I am including a header file that is a stdio.h then I am declaring a function whose name is swap. Its written type is void and it will receive two arguments of integer type. So this statement is function declaration. After function declaration, I am defining main function inside main function. I am declaring two variables A and B. Now to receive values of A and B. I am going to display the message enter two values on console with the help of printf to receive those values from user. I am writing scanf statement and the entered values will be stored inside A and B variables. Now, I am again using printf statement which will display the values on console with the message before swapping. So A equals to %d and B equals to %d then A comma B. So this way values of A and B will be displayed before swapping on console. Now I am calling the functions swap which will pass values of A and B inside function definition. So this statement is function calling. After completion of function call, I want to print values of A and B again. So here I am changing this message after swapping and then I am writing return 0. So this is the complete code of main function. Now I am defining definition of swap. Here I am using two more variables P and Q. So this block will be known as function definition. Here you can see at the time of function call values of A and B are passed and inside definition those values will be received inside P and Q. So at the time of function call A and B are known as actual arguments and in function definition P and Q are formal parameters. So P and Q are receiving values of A and B. So when this program will be executed, separate memory blocks for AB and PQ will be allocated. Now I am declaring one more variable R for swapping purpose. So I am writing the statements for swapping. So these are swapping statements. R equals to P, P equals to Q and Q equals to R. So now we have to check whether the outputs before swapping and after swapping will be same or different. So I am entering 10 and 20. You can see the output before swapping 10 and 20, after swapping 10 and 20. So in this call by value method, both the outputs are same before swapping and after swapping. So that means swapping is done with P and Q formal parameters, but it has not affected A and B. Now if you want to apply the change effect of P and Q on A and B variables, for that purpose you have to use call by address. So now I am going to demonstrate you the use of call by address with the help of this program. So I am going to modify this program so that you can understand the working of call by address. So first I am modifying function declaration. Here I am passing addresses or you can say pointers. So I am using int asterisk comma int asterisk. Then at the time of function call, I have to pass address of A and address of B. These addresses will be received by P and Q pointers. So P and Q will be receiving addresses of A and B. Now if I modify P and Q, then A and B will be modified automatically because they are having addresses of A and B. So this way I have modified this program. P and Q are receiving addresses of A and B. So whenever I will be modifying P and Q, automatically values of A and B will be modified because P and Q pointers are containing addresses of A and B. So now I am again executing this code. I am again entering 10 and 20. This time you can see the output before swapping values are 10, 20, but after swapping values are 20 and 10. So this way with the help of call by address, we can change values of actual arguments with the help of formal parameters. But here you have to remember that formal parameters must be pointers because pointer contains address of a particular location. Then if you modify pointers, then that actual location will be modified automatically. So here in this program, I am modifying P and Q, but P and Q are modifying actual arguments that are A and B. That's why this change is reflected in actual arguments with the help of pointers. So I hope you have understood the difference between call by value and call by address. So in case of call by value, values are passed through calling statement, but in case of call by address. Addresses are passed through calling statement. So this way, those are different in working style. So one is based on values and one is based on addresses. I hope you have understood the difference between call by value and call by address that is available in C programming. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app Techimace, which is available on Google Play. Thank you for watching this video.