Create a program that finds the elements of the given two-dimensional array that match the input numerical values by linear search. Considering that there may be multiple matches, the number of matches should be displayed after the search is completed. Execution resul I want to do
% ./a.out
Please enter a number: 1
a [0] [0] is 1
There was one 1 in the element of the two-dimensional array a
% ./a.out
Please enter a number: 5
a [1] [1] is 5
a [2] [0] is 5
There were two 5s in the element of the two-dimensional array a
% ./a.out
Please enter a number: 27
There are no 27 elements in the 2D array a
Actual execution result
./a.out
Please enter a number: 1
a [0] [0] is 1
There were 32768 1s in the elements of the two-dimensional array a
There is no 1 in the element of the 2D array a
source code
#include <stdio.h>
#define INDI 3
#define INDJ 4
int main ()
{
int a [INDI] [INDJ] = {
{1, 8, 11, 3},
{9, 5, 0, 7},
{5, 10, 4, 6},
};
int n;
int i;
int yoko;
int tate;
int result;
int count;
/ * Add variable declaration as needed * /
printf ("Enter a number:");
scanf ("% d", & n);
for (tate = 0; tate <3; tate ++) {
for (yoko = 0; yoko <4; yoko ++) {
if (n == a [tate] [yoko]) {
count ++;
printf ("a [% d] [% d] is% d \ n", tate, yoko, n);
printf ("There were% d% d in the element of 2D array a \ n", n, count);
}
}}
printf ("There is no% d in the element of 2D array a \ n", n);
return 0;
}