 Hello friends, I am Sanjay Gupta. I welcome you on my YouTube channel. You can watch various programming related videos here. My channel contains more than 800 videos. You can search these videos through a keyword programming by Sanjay Gupta. In this video, I am going to demonstrate you how you can pass structure data type into functions in C programming. For example, I am going to implement some of complex numbers. So first of all, I am going to include a header file stdi.h. Now to implement structure, I have to use a keyword struct name of structure will be complex. And here I am going to declare two variables real and imaginary. After structure declaration, I am going to declare a function. So this is function declaration. Here you can see this struct complex is written type. It means the function will be returning a structure variable. Name of function is sum. And I am going to pass two arguments of type struct complex. So first argument and then second argument. So this sum function will be receiving two arguments of structure type. So in this example, you will be able to learn how we can pass structure variables as argument and how we can return structure variable through a function. So this statement is declaration of function. Now I am going to define main function so that we can receive inputs from user. So here I am going to declare three variables C1, C2 and C3. Now first I am going to receive values for first complex number. So enter first complex number scanf then two times C1 dot r sorry C1 dot imaginary and here instead of r I have to write real. So real value will be stored inside C1 dot real and imaginary value will be stored inside C1 dot imaginary. So this way first complex number will be entered by the user and stored in first complex variable. Now for second complex number again I am going to use these printf scanf statements. So this way values for both complex numbers will be available. Now I am going to call the function sum and I am going to pass structure variables as an arguments. So C1 and C2 both are arguments and the returned value will be stored inside C3. So this is a function calling. Now the result will be stored inside C3. So I can display that result on output screen with the help of this printf statement. So this way I have implemented the complete definition of main function. After this I am going to define definition of some function. So here I have to receive two complex variables and these variables are of type structure. So this block will be known as function definition. Now inside this function I am going to implement the logic which will add values of two complex numbers. So temporary complex variable is declared here. Now T dot real equals to C1 dot real plus C2 dot real. So this way real value of first complex number is added with real value of second complex number and that is stored inside temporary complex number that is T dot real. Now T dot imaginary equals to C1 dot imaginary plus C2 dot imaginary. So this way imaginary values are added. So T complex variable is containing both real and imaginary values. So I can return it to the keyword. The statement is return T. So the values of T will be returned at the calling statement which is available at line number 19 and at line number 19 C3 will be receiving the return value and through line number 20 those results will be displayed on output screen. So this way I have implemented the complete code in front of you. Here I am passing structure variables as an argument and I am returning structure variable through a function definition. Now I have to execute this code so that you can see whether it is working properly or not. So I am going to enter first complex number value. So I have entered two as real number and four as imaginary number. For second complex number I am going to enter three as real value and six as imaginary value. So after addition real is printed as five and imaginary is printed as ten. So which is correct. This way you can see the program is working properly. The logic which I have implemented is working fine. So I hope you have understood how we can pass and how we can return structure variables through function. If you want to watch more programming related videos you can follow my YouTube channel. Thank you for watching this video.