 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can calculate square and cube of a number using hash define in C programming. Before starting you can note how you can search my YouTube channel. You can type my name Sanjay Gupta in YouTube. My channel will be available there. You can watch various programming related videos here. Now I am going to demonstrate you first how to calculate square with the help of hash define. So first of all I have included a header file that is STDIO.H. Now I am using hash define. So hash define is a preprocessor. Here I am going to create a macro whose name will be square and it will be receiving a value in N. So this square is a name of macro. It will be receiving a value inside N. So whenever you will be using this notation it will be replaced with this notation that is N into N. So this value N will be multiplied with itself and the result will be stored in a variable or it can be displayed on output screen. Now I am going to define main function so that I can demonstrate you how you can use this square macro so that you can calculate square of a particular number. So this way I have used this square macro. Here I have passed 5. So this square of 5 will be replaced with 5 into 5 because 5 will be assigned into N that is a parameter available in a macro and this square of N will be replaced with N into N. So value of N is 5. So square of 5 will be replaced with 5 into 5 automatically. Now I am going to execute this code so that you can see the results. You can see the output. It is showing square equals to 25. So 5 into 5 is equals to 25. So here I have directly printed the result on output screen with the help of printf. Now if I want to store this result in a variable so I have declared two variables N and R. N is 5 and R is a variable which is having nothing right now. So I can use this macro like this. So square of N its replacement will be N into N that is 5 into 5. Result will be stored inside R variable. So this time I can use R here. So this macro will be assigning result into R variable and that will be displayed on output screen. Again I am going to execute this code. You can see the result. Square equals to 25 is displayed on output screen. Now if I want to read this value from user for that purpose I can write printf and scanf statements. So here value of N will be provided by the user then its square will be calculated and the result will be assigned into R and then the calculated result will be displayed on output screen. So you can see it is asking for a number. So this time I am entering 10. You can see the output. It is showing square equals to 100. So this way I hope you have understood these different methods to use square macro in the program. Now I have to calculate cube. So in same program I am going to implement another macro. So here name of macro is cube. Its parameter is N and its replacement value is N into N into N. So this time N will be multiplied 3 times. So this way I have used second macro that is cube which will calculate cube of N. So I have directly stored its calculated result into R variable and that result will be displayed on output screen. So I have executed this code. It is again asking for a number. I am entering 10 again. So you can see the output. It is showing square equals to 100 and cube equals to 1000. So I hope you have understood how we can create multiple macros which are working like a function and these macros are calculating square and cube. So you can implement any other operation with the help of macro like I have calculated square and cube in this program. I hope you have understood how we can pass parameter to macro in C programming. If you want to watch more programming related videos you can search my name Sanjay Gupta in YouTube. My channel will be available there. You can also download my programming app Techimus which is available on Play Store. Thank you for watching this video.