 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 those videos through the keyword programming by Sanjay Gupta. In this video, I am going to demonstrate you how you can pass union into functions in C programming. For example, I am going to implement the program which will read and display mouse button click coordinates. So you all know that each mouse has two buttons left and right and for each button we have two coordinates X and Y but at single point of time we can read or we can click either left or right mouse button. So we have to store a particular value at a particular time. So for saving the memory here I am going to use the union. So first I am going to include a header file stdio.h. Now I am declaring union whose name is mouse. Inside this I am declaring two variables L and R. L will be storing left mouse button coordinates and R will be storing right mouse button coordinates. There will be two coordinates that that's why size of these variables are two as in form of arrays. So I am declaring this mouse as union. So I can store value into L or I can store value into R at a particular time. I can't store values into both variables because I am using union as a keyword. So union shares the memory locations and here I have to store values for left button or right button that's why union is the best possible data type for this kind of problem. Now I am going to declare a function whose name is display and inside this function I am going to pass an argument whose data type will be union mouse. So this is function declaration. Now I am going to define main function where I will be reading values from user. Here I am going to read left mouse button coordinates. This way both x and y coordinates are stored in M1.L0 and M1.L1 positions. Now I am going to call display function and I am passing union variable and this is calling of function. So this way I have defined main function. Now I am going to define definition of display function. Here I am going to just display the values on output screen. So left button x coordinate equals to M1.L0 F button y coordinate M1.L1 position. So this way I have passed union variable into a function. I simply read the values of this union variable in main function and I have displayed those values on output screen in display function definition. So friends this way you can pass union variables into functions. Now I am going to execute this code and I am passing coordinates for left button 30 is the x coordinate and 40 is the y coordinate. You can see the output. It is showing left button x coordinate as 30 and left button y coordinate as 40. So this way you can see the program is working properly. I have passed union variable into function for processing purpose. I hope you have understood how we can pass union into a function. Though union is used very less but still you must know how you can pass union variables into function. So if you want to watch more programming related videos you can follow my YouTube channel. Thank you for watching this video.