An algorithm and pseudocode to
search for an item in a 2D array
using C programming language:
Algorithm:
Start
Declare a 2D array of size m x n
and an item to be searched.
Initialize a flag variable to indicate
whether the item is found or not.
Iterate over the rows and columns
of the array.
Check if the current element is
equal to the item to be searched.
If yes, set the flag variable to true
and
break the loop.
Otherwise, continue iterating.
After the loop, check the flag
variable.
If it is true, print the indices of the
item found.
If it is false, print a message
indicating that the item was not
found.
Stop.
1. start
2. declare a 2D array of size m x n
and an item to be searched
3. initialize a flag variable to false
4. for i = 0 to m-1 do
5. for j = 0 to n-1 do
6. if arr[i][j] == item then
7. set flag to true
8. print "Item found at
indices (" i ", " j ")"
9. break out of both loops
10. end if
11. end for
12. if flag == true then
13. break
14. end if
15. end for
16. if flag == false then
17. print "Item not found in the
array"
18. end if
19. stop