# Occurrence of number in Matrix by R4R Team

Matrix:
-Multidimensional Array
-Matrix consist of the rows and columns.

Syntax-
array[row][column]
//Martix with numbers of rows and columns

Example-
Matrix is:
1 2 1
4 3 1
1 1 1
occurrence of 1 is 6
occurrence of 4 is 1
etc

program-

#include< stdio.h>
int main()
{
int a[10][10],r,c,i,j,count=0,num;
printf("Enter rows and columns in matrix\n");
scanf("%d%d",&r,&c);
printf("Enter %d number in matrix\n",r*c);
//input in matrix
for(i=0;i< r;i++){
for(j=0;j< c;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Matrix is\n");
for(i=0;i< r;i++){
for(j=0;j< c;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
printf("Enter number to search\n");
scanf("%d",&num);
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
{
if(a[i][j]==num)
count++;
}
}
printf("Occurrence of %d in matrix is %d",num,count);
}

output-

Enter rows and colums in matrix
3 3
Enter 9 number in matrix
1 2 3 1 4 5 1 6 7
Matrix is
1 2 3
1 4 5
1 6 7
Enter number to search
1
Occurrence of 1 in matrix is 3