 Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to explain how you can calculate some of it using pointer. So before starting, I just want to give you a brief information. If you go to a detailed or description of this video, you will find links of various playlist related to key language videos. So you can follow them if you want to watch more programming related videos. So after this, now I'm going to tell you how we can implement this problem with the help of C language, right? So initially I'm starting from main function. So here I'm going to declare an array whose size is 5 and I'm initializing these values. So size of array is 5 and it is having these 5 values as initial value. So let's say in memory, these 5 blocks will be allocated to this array. Name of array is A. So through A, you can access all the locations and these are indexes, right? And here I am putting values. Now see the data type of this array. So data type is integer. So in case of C programming, whenever we declare any variable of type in, so 2 bytes, memory will be allocated if you are using 16 bit compiler and 4 byte memory will be allocated to one variable of integer type if you are using 32 bit compiler. So let's say I'm using 16 bit compiler. So it means each block will be having 2 bytes allocated. So for this block, we have 2 bytes. For this block, we have 2 bytes. So total allocated memory will be 10 bytes. Total allocated memory will be 10 bytes, right? So whenever memory is allocated to any variable, so along with memory allocation, some addresses are also provided by the memory. So let's say for this first block, which is having 2 bytes, so 2 addresses will be available. So I am assuming that first address is 101 and second address is 102. So I am again limiting, I am assuming that these addresses are allocated but in real time or actually these addresses can be different. So this way this block will be having 2 addresses as 103 and 104, then 105, 106, 107, 108 and 109 and 110. So total 10 addresses are allocated for this array. So why I mentioned these addresses because we are going to access locations of array with the help of pointer. So now I am going to declare pointer. So pointer is declared with asterisk sign. So this is a p pointer variable and one more variable I am declaring as i and one more variable I am declaring as s, which will be having some of this array. Now I am writing the statement p equals to address of a. So this means a zero locations address will be assigned into p pointer. So let's say this is p and a zero index is this and its beginning address is 101. So p will be having beginning address of that zero index which is 101. You can also write this p equals to a, both are same. So if you write this or this both will work same because name of array automatically provides base address of the memory location. So for this array this 101 will be considered as the base address and if you write name of any array and you assign that into a pointer. So automatically base address will be assigned into that pointer. So remember that you can write this or you can write this both will work same. Now I am going to iterate a loop. So this loop will repeat 10 times and you will see inside this loop I am not going to use this name of array. I am just going to use this pointer so that I can access the value. So here I am writing this s equals to s plus asterisk p. So here the asterisk means value at address. So this asterisk will identify which value is available on the address which is available within p. So p is having 101 as address. So now asterisk will dereference that address. So if this address will be dereference, so you can see it is having 11. So this 11 will be added into s. Now we want to move to next location that is 103. So for this I am writing p plus plus. So here again you need to note whenever we increase any address, whenever we increase any address, so let's say we are increasing this pointer which is having an address stored. So actually we are increasing this address. So whenever we increase any address, so you need to see the type of pointer. So here type of pointer is integer. So here this address will be incremented by 2 automatically. So next value will be stored 103 automatically into this pointer. So remember that if you have pointer as integer type, so address will be incremented by 2. If pointer is of type flow then address will be incremented by 4. If it is of character type then it will be incremented by 1. And I am assuming that we are using 16 bit compiler. So according to that I am taking these examples. So whenever you perform p plus plus, so 2 bytes will be jumped, so p will be having 103. Then i will be incremented, so next rotation will be performed. So this time it will dereference 103. So 103 is having 12. So 12 will be added into s and again p will be incremented. So p is having 103. So again 2 bytes will be incremented because type of p pointer is integer. So it will be having 105. So this way 5 times this will be incremented and all 5 locations we can access with that of this pointer. So 2 things are important here. First is as soon as p which is dereferencing the value which is available on a particular address and p plus plus is moving pointer from one location to another location of the address. So here you can see I have not used array anywhere. I am just using addresses of that allocated array with help of pointer. After completion of this loop, I can write printf backslash and sum equals to percent b and s. So this way you can see I accessed all available locations of array with help of pointer. So you can also implement this program in your laptop so that you can verify whether it is working correctly or not. So I hope you understood whatever I explained in this video. So I hope you understood how we can manage all the locations of array with help of pointer. So if you want to watch more programming related videos, you can open my channel, go to playlist and there you can find various videos. And also you can go to description of this video where I have posted links of various playlist related to C language. So you can watch them too. Thank you for watching this video.