 Hello friends. I am Sanjay Gupta. In this video, I'm going to demonstrate you how to access and modify a memory location through pointers. Before starting, you can note my information. You can follow or subscribe my YouTube channel through the URL youtube.com slash Sanjay Gupta underscore tech school. You can download my programming at TechMS that is available on Google Play. Now, in this video, I'm going to demonstrate you how you can access value stored at a memory location through pointer or through its address and how you can modify value of that memory location through its address using pointer. So I'm first including a header file that is stdio.h. Now inside main function, I'm declaring a variable A and it is initialized with a value 5. Then I have declared a pointer. Name of pointer variable is P to assign an address or address of any variable. I have to write P equals to address of A. So here this M% means address of. So address of A variable will be assigned into P pointer. So here you can say that P is pointing to the location whose name is A. So if you want to access a memory location through the name, then you can use A and if you want to access value of that location through address, then you can use P pointer. Now I'm writing a statement A equals to A plus asterisk P. So what does it mean? It means A equals to 5 plus than asterisk. Now we have to assume addresses. So I am assuming that address of A location is 101 and this 101 is stored inside P pointer. So that's why I have mentioned here asterisk 101. So if I remove this asterisk from the expression, so it will be A equals to A plus P. So value of A is 5 and value of P is 101 because P is holding address of A. Now I want to access the value which is available inside 101 location. For that purpose I have to use this asterisk notation. So here this statement will be asterisk 101. So you have to understand asterisk means value at address. So value at this address that is 101. So 101's value is 5. So this statement asterisk 101 will be replaced in 5. So now I can write this statement like this A equals to 5 plus 5. So 5 plus 5 equals to 10 which will be assigned into A. Now I have to print the value of A on console. So first I am printing value of A to variable A. Now with the help of second printer I am printing value of A through P and here I am using asterisk P. So you can see new value of A is 10. So this A will be printing 10 on console. Its output will be 10 because we are directly using variable name. But here I am using asterisk P. So the meaning of asterisk P is asterisk 101. Again remember that I have assumed this address that is 101 is address of A. But actual memory location or memory address will be different as per the availability of your memory. So asterisk P means asterisk 101. So while A will be receiving 10 then its address gets automatically updated. It means if we are assigning 10 into A variable then 101 will be having automatically 10 because A and 101 both are pointing to same location. Or you can say address of A location is 101. So if A is containing 10 then value of 101 is automatically 10. So both will print 10 on console. Now we have to check whether it will happen or not. So you can see the output value of A is 10 and value of A through P is also 10. So this way you can see I have received value of variable through the pointer. So here I have used asterisk P. So asterisk P provided 5. Then 5 and 5 both are added and the new result is assigned into A. And then through second time asterisk P I have again accessed value of that variable that is right now 10. So this way till now I have received a memory locations value through its address with the help of pointer. Now I want to modify a memory location through its address with the help of pointer. So for that purpose I have to use another example. So right now value of A is 10 and its address 101 is also containing value 10. Now I am writing asterisk P equals to asterisk P plus A. So here you can see at left hand side of equals to sign I am using asterisk P. So here the value of A will be modified with the help of its address. So this can be converted into this notation. We can write 10 in place of A directly because A is representing that memory location through its name. But asterisk P both the sites representing addresses. So asterisk 101 means value at address. So now you can write it like this. Asterisk 101 is providing 10 because 101 is containing 10 and A is also 10. So 10 plus 10 is 20. So value at 101 will become 20. So here you can see that 101 is receiving new value that is 20. Now I want to print the output again with the help of these two statements. So 101's value is 20 now. So 101 is pointing to a location. So new value of A will be automatically 20 and asterisk 101 will also print 20. So friends, I hope you have understood how I have first modified a value through its variable name. Then its address gets modified automatically. In second example, I have modified value of a memory location through its address. But here its name automatically receives modified value. This is because both are pointing to the same location. So now you can imagine that A and 101 is name of a location and 101 is address of a location. Both are pointing to the same location. So as I modify value of A, 101 automatically receives modified value. If I modify value of 101, A automatically receives modified value because both are pointing to the same location. So if you are printing value through its variable name or through its address, both will print same values every time. So now again I'm executing this code. You can see the output. First output is 1010 and second output is 2020. So this way I have accessed and I have modified a memory location through its address with the help of pointers. So this is a small pointer arithmetic, which I have demonstrated you in this video. I hope you have understood the depth of pointer, how we can use pointer to point address of a particular location and how we can access that location through the address and how we can modify the value which is stored at that memory location with the help of its address. In both the cases, we need to use pointers. So I hope you have understood all the logics which I have demonstrated you. 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 that is Techimage which is available on Google Play. Thank you for watching this video.