 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can calculate some of all elements of a matrix by passing 2D array into a function. Before starting, you can note my information. You can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tax pool. You can download my programming app Takimus, which is available on Google Play. Now I am going to implement the code in C programming. So first I am including a header file stdio.h. Then I am implementing a function declaration int sum a. This a is optional, so I am removing it. So the declaration is int sum int dimension r 3 by 3. So return type of function is integer name is sum and it will receive a 2D array of integer type. In case of 2D array, we have to mention dimensions in case of declaration and definition. This is optional in case of 1D array. Now first I am implementing main function. So inside main function, I am declaring a 2D array with some variables declaration. Now I am using printf statement, which will display the messes, enter elements on console. To receive those elements, I am applying nested loops. Here i loop will provide row indexes, whereas j loop will provide column indexes. With the help of this scanf, all the elements will be stored inside a matrix. Now I have to call the function. So for that purpose, I am writing this statement. This is function call. So here you can see I have passed a array as argument. Sum is name of function and the returned value will be stored inside s. Now I am printing sum on console with the help of this printer. So this is the complete implementation of main function where calling statement is available and above main function is declared. Now I have to define definition of sum function. So for this purpose, I am implementing this block which will be function definition. So inside this function, I am declaring some variables. Now I have to apply for loop or you can say nested for loop because I have to process 2D array. So here you can see I have implemented first i loop which will provide row indexes. Then I have implemented j loop which will provide column indexes. Now for addition purpose, I am implementing the instruction s equals to s plus aij. So this will add all the elements available in a matrix into s variable. So after completion of both the loops, I can return the value which is available inside s variable. So this is the complete program which is implemented in front of you in C language. So now I am going to execute this code. You can see here I have to enter the elements. So I am entering these values. You can see the output sum equals to 45. So if you add all the elements starting from 1 to 9 which are available in a 2D array in form of matrix, the sum will be 45. So the program is working properly. So I hope you have understood how we can pass a 2D array into a function and how we can calculate sum of all the elements which are available in that 2D array in form of matrix. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app Techimage which is available on Google Play. Thank you for watching this video.