 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can use Caloc and free functions of dynamic memory location in C programming. Before starting, you can note my information. You can connect with me by following these details which are available in front of you. You can open my YouTube channel by typing my name Sanjay Gupta in YouTube search bar. My channel will be available there. You can open it. Here various programming related playlists are available. You can improve your programming skills by watching these videos which are available in this channel. You can follow my YouTube channel by subscribing my YouTube channel through the link which is available here in red color. Now I am going to demonstrate you the use of Caloc and free functions. So first time including two header files. First one is stdio.h and second one is stdlib.h. Now I am defining main function. Inside main function, I am declaring a pointer variable n and variable i. Now with the help of printf, I am going to display the message enter size of array. So I want to read multiple values. That's why I have mentioned this message. Now with the help of scanf, I am going to read that size from user. So scanf will read that size and the value will be stored inside n variable. Now with the help of caloc function, I am going to allocate dynamic memory. So this dynamic memory will be allocated at execution time. So you can see how I am implementing this. So this statement is responsible for dynamic memory allocation. So here I have used caloc function or you can say I have called caloc. Here two arguments are passed. First is n which will provide number of blocks and size of int means the size of each block which will be available in that memory and the allocated memory base address will be typecasted into integer pointer and that will be stored inside p pointer. Now with the help of p, I can access all the locations of the array which is allocated through caloc dynamically. So now I am going to print a message that is elements r. So this message will be displayed on console. Now I am just going to implement a for loop which will display all the values which are available at different locations allocated through caloc. So caloc function automatically fills zero value in each block of dynamically allocated memory. So I am just going to display those elements through printf. So for that purpose I am using this notation as to risk p plus i. So p is having base address. I have added i in that base address and that base address is the reference with the help of this asterisk sign. So the value which is available on a particular address will be displayed on console. Now after completion of this loop, I can call free function. So free function is used to deallocate dynamically allocated memory. And then at last I can call sorry at last I can write return zero. So this is the complete implementation of caloc and free functions. Now I can execute this code. So I am entering four as size of array. You can see the output. All the elements are printed as zero because caloc automatically fills zero at different locations which are allocated through it. So with the help of this for loop, I have displayed those blocks and with the help of free, those dynamic blocks will be automatically freed so that they can be used by another application which is currently being executed in your computer. Now I am going to read values from user and then I am going to display those values with the help of a loop. So I am copying these statements and I am pasting them here. So now after dynamic memory location, I am going to read n numbers from user and then those n elements will be displayed from sorry those n elements will be displayed on console. So this message enter elements will be displayed on console. Loop will repeat n times then in place of printf I have to use scanf and I just have to pass addresses of each location. That's why I have removed asterisk sign. So this block is responsible for reading part and this block is responsible for printing part. So this way after dynamic memory location, I can read elements from user and I can display those elements back on console. Now I am executing this code. You can see it is asking for size. I am entering four. So I have to enter four elements. So I am entering one, two, three, four. You can see the output. It is showing four elements which is entered by me as output. So this way I have demonstrated you how you can use calop and free functions in C programming which are available for dynamic memory allocation and for dynamic memory deallocation. So I hope you have understood how you can use these functions for dynamic memory allocation. If you want to watch more programming related videos, you can follow or subscribe my youtube channel through the url youtube.com slash sanjay gupta underscore tech school. You can download my programming app Techimace which is available on google play. Thank you for watching this video.