 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can count frequency of a number in matrix by passing 2D array into function. Before starting, you can note my information, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app Techimus which is available on Google Play. Now I am going to implement the code in front of you with the help of C. So first I am including a header file stdi.h then I am declaring a function whose name is count, its return type is void and it will receive two arguments. First one is 2D array of integer type and second one is integer variable. So this statement is function declaration. After that I am defining main function where I am declaring a 2D array then ij variables and then the number which whose frequency we count we want to count. So to receive elements, I am going to display the message enter elements using printf. Now I am implementing for loop nested for loop so that elements of 2D array can be received from user. Here you can see i loop will be providing row indexes and j loop will be providing column indexes. And to read elements from user I am writing scanf which will receive elements from user. So after reading 2D array I am again printing a message enter the number whose frequency you want to count. So this will be the number whose quantity or frequency we want to count that how many times that number is available in the matrix or you can say occurrence of the number. So I have stored that number inside n variable. Now I am calling count function where I am passing a 2D array and n that variable which is having the number. So this statement is function calling and then return 0. So this way I have implemented the main function. Now I am defining definition of count. So this block will be containing definition. So we can write here that this is function definition. Inside this function I am declaring the variable i another variable j and then variable c whose initial value is 0. Now for logic I am applying nested loops. Here you can see i loop will be providing row indexes and j will be providing column indexes. Now I have to apply f condition which will check whether aij is equals to n or not. So if this condition is true then that n number or you can say the number which is stored inside n variable is present in the matrix. So if this condition is true then only c variable will be incremented otherwise not. So these two nested loops will be repeated and n sorry these two loops will be repeated and the value which is available inside n will be compared each time with a of ij. Whenever the condition is true then only c will be incremented otherwise not. So after termination or after completion of repetitions of these nested loops I can print the counted result on console. Number is present person the times and I am printing value of c. So this is the complete implementation. Now I am going to execute this code. So you can see I am entering the values. Now I am entering the number which I want to count is 3. So you can see the output number is present 3 times. So you can see in the matrix 3 is available 3 times only. So the output is correct. The program is working properly. Now I am modifying this program. I am removing the return type void and I am placing int here. So in definition I am modifying this int. Here I have used c variable which I can return to main function and I am removing this printf from here and I am pasting this printf in main function. Now at calling I am receiving the return value inside c variable and I am declaring the c variable in main. So you can see declaration is containing return type main then calling is receiving the returned value into c and then c is printed on console using printf statement. Now return type of definition is also end and then it is returning the counted value which is available inside c. So this way you can also implement this function that we want to return the result from the count function to main function. Again I am executing this code. So you can see this time this time also I have entered 3 as the number which I want to count. So the output is number is present 3 times. So you can see the 2D array is available 3 times only. So in both the ways program is working properly. I hope you have understood how we can count frequency of a particular number in matrix by passing 2D array into function. If you want to watch more programming related videos you can follow or subscribe my youtube channel through the url youtube.com slash sanjaybukta underscore tax school. You can download my programming app Techimace which is available on google play. Thank you for watching this video.