 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can swap elements of two 1D arrays using pointers. 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 Techimus, which is available on Google Play. Now I am going to demonstrate you the code which is implemented in front of you, which will swap elements of two 1D arrays using pointers. So in first statement, you can see I have declared some variables A and B both are arrays P1, P2 are pointers and I is a variable which will be used to repeat some set of instructions with the help of loop. After this variable declaration, I have implemented three statements in which first is printf, which will display the message enter 10 elements of first array on console. Then through this for loop scanf statement will be repeating 10 times and all the 10 elements which will provided by the user will be stored inside a array. After completion of this loop, the second segment will be executed, which will display enter 10 elements of second array message on console and next 10 elements of second 1D array will be stored inside B array. After reading elements of A and B, I have to assign addresses of both the arrays into P1 and P2 pointers. So for that purpose, I have used P1 equals to A and P2 equals to B statements. So here you have to notice that name of array provides base address of the array. So A is providing its base address into P1 and B is storing its base address into P2. Now I can access elements of A through P1 pointer and B through P2 pointer. So for swapping purpose, I have used this loop which is repeating 10 times and here these three statements are available which will swap elements of A and B arrays with the help of pointer. So here asterisk means value at address. So when I will be writing asterisk P1, it means P1 is containing an address and I want to receive the value of that address. So for that purpose, I have written asterisk P1. So asterisk will provide the value which is available at the address and the address is stored inside P1. So P1 and P2 both are pointing to some addresses and their values will be received with the help of asterisk sign. So this way all the elements are added and subtracted and the results will be again assigned into values of P1 and P2 pointers. Now for pointing to the next location, I have added P1 and P2 by 1. So initially P1 and P2 are pointing to the base locations of array. To move to the next location, I have incremented both the pointers by 1. So this way this loop will repeat 10 times and all the locations of A and B arrays will be interchanged or swapped with the help of pointers. And this method is implemented without using third variable. So after completion of this for loop, I can print the results of A and B arrays with the help of their names. So here you have to see that I have received elements of array through array name and now I am going to print the swapped values again with the help of array names. But for swapping purpose, I have used their addresses with help of pointers. So now if A and B will be printing swapped values, then this operation is correct. Otherwise, this is incorrect. So now I have to check whether the program is working properly or not. So I'm entering 10 times 1 in first array. Now it is asking for the 10 elements of second array. So this time I'm entering 4 in second 1D array. So you can see the output. First row is printing 4 and second row is printing 1. And here in this printf, I have printed A first and then B. So A is printing 4 and B is printing 1. But I have entered 1 into A array and 4 into B array. So this way I have interchanged values of A and B arrays with help of pointers. So this way you can swap elements of 2 1D arrays using pointer. You can use any particular method either using third variable swapping or without using third variable swapping. So I preferred without using third variable swapping method. So I hope you have understood how you can swap elements of 2 1D arrays using pointers. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel through the URL youtube.com. You can download my programming app Techimace which is available on Google Play. Thank you for watching this video.