 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can swap elements of two 1D arrays by passing array into function using pointer. Before starting, you can note my information, you can follow or subscribe my YouTube channel through the URL youtube.com slash tanjaygupta underscore tech school. You can download my programming app tech image which is available on Google Play. Now I am going to implement solution of this problem. So header file is stdio.h. Now I am declaring a function whose name is swap. Its written type is void and it will receive two arguments that will be addresses of two 1D arrays. So that's why I have declared integer pointer twice. So this statement is function declaration. Now I have to define main function. Inside main, I am declaring two arrays and a variable i. Now with the help of printf, the masses enter 10 elements of first array will be displayed on console. To read those 10 elements, I am applying a for loop which will repeat 10 times and it will read 10 elements from user and all the elements will be stored inside this array. Now I am copying these statements and I have pasted them. So I am modifying these statements so that second array can be read from user. So this way, first array A will be received from user and second array B will be received from user. Now I have to call swap function so that I can pass both the arrays inside this function definition. So this statement is function calling statement. Swap function is called here. Base addresses of A and B are passed inside function definition of swap. Now swapping operation will be done in function definition. So we are passing addresses. So interchanged values will be available in this main function because it is performing call by address operation because we are passing addresses. So A and B which I have passed in this function call will be updated automatically. So now I can print the swapped values on console in main function. So I am implementing another loop which will repeat 10 times and it will display values of A and B arrays on console. So this is the complete implementation of main function. Now I have to define definition of swap. So for that purpose I am implementing these instructions. So this block will be known as function definition. Inside this function definition I have to implement the swapping process. So for that purpose I am implementing a for loop. Inside this for loop I have to apply the swapping process. So for that purpose I am implementing swapping without using third variable. So asterisk p1 equals to asterisk p1 plus asterisk p2 then asterisk p2 equals to asterisk p1 minus asterisk p2 and asterisk p1 equals to asterisk p1 minus asterisk p2. So these three statements are for swapping asterisk p1 is representing A array and asterisk p2 is representing B array. So right now they are containing base addresses. So base address value will be swapped through these three statements. Now I have to move to the next location. So for that purpose I am applying p1 plus plus and p2 plus plus. So by incrementing these pointers I will be pointing to the next location of arrays A and B. So this process will be done 10 times. So all 10 locations of A and B arrays will be interchanged or swapped through this logic. And the updation will be done automatically at calling statement because we are applying call by address process here. So now I am going to execute this code so that you can understand whether it is working properly or not. So in first array I am entering 1. In second array I am entering 4. Sorry it got terminated. Again I am executing this code. In first array I am entering 1. In second array I am entering 2. You can see the output. Here I have printed A of I and then B of I. So A is printing 2 and B is printing 1. So values are interchanged with the help of this logic. So I hope you have understood how we can pass two arrays into function. Then in function definition I have swapped the values of array using pointer. And automatically here I have applied call by address method. So result is displayed in main function only and I have not returned any value through swap function definition to main. So this way I have passed arrays into function. I have swapped the values of arrays with the help of pointers. 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 Techimus which is available on Google Play. Thank you for watching this video.