 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can calculate factorial of a number using pointer. Before starting, you can note my information, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore text You can download my programming app Techimace, which is available on Google Play. Now I am going to implement a code in front of you, which will demonstrate you how you can calculate factorial of a number using pointer. So I am defining main function. Inside main function, I am declaring a variable n, which will receive a number from user, then a pointer p, then f, which is initialized with one, and then variable i. Now, first I am using printf statement, which will display the message enter a number on console. The entered number will be received by scanf, and that number will be stored inside n variable. Now for calculation purpose, I have declared a variable f, which is initialized with one. But now I am assigning address of f into p. So for calculation purpose, instead of f, I will be using p pointer, because p is containing address of f. And whenever I will be modifying values through p, then that effect will be made upon f variable automatically. So for that purpose, I am using a loop, which will repeat n times. And inside this loop, I am going to apply the statement that is asterisk p equals to asterisk p into i. And I can include this asterisk p into parenthesis. So this way you can see, without pointer, we have to write f equals to f into i. So if I am not using pointer, then I have to write f equals to f into i. Now instead of f, I am using asterisk p. So p is containing address of f. So if I am modifying value of, sorry, if I want to modify value of f through pointer, then I can write asterisk p equals to asterisk p into i. So asterisk p will be providing value of f, then it will be multiplied with i, and then the result will be stored again asterisk into asterisk p. So p is pointing to f, so the updated value will be automatically stored inside f variable. Now after completion of this calculation, I can print the calculated factorial on console using this printf statement and with the help of f. So here you can see at the time of calculation, I have not used f directly, but I have used a pointer p which is pointing to the address of f. So pointer has modified the value of f. That's why I am able to print the calculated result with the help of f variable. Now I am using return 0. Now I am going to execute this code. I am entering 5 as a number. You can see the result factorial equals to 120. So the output is correct. So program is working properly. This way I have calculated factorial with the help of pointer. I have not directly used the variable which is responsible for printing the factorial result, but instead of that variable, I have used its pointer. So whenever pointer points to a location through its address, then through that pointer we can receive that value which is available into a variable and we can also modify value of that variable with the help of pointer. So through p, I have managed both the requirements. I have accessed value of f through p and I have modified value of f through p pointer. So that's why this output is displayed on console correctly. I hope you have understood how we can use a pointer for any calculation instead of variables. 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 TechMS which is available on Google Play. Thank you for watching this video.