Module: Linear and binary search for elements in an array


Problem

4/7

Linear search - 2

Theory Click to read/hide

Linear array search
Try to fix the task from the previous task so that it works correctly even if the required element is not in the array. 
Hint: if the required element is not in the array, then it is necessary to exit the loop as soon as the array is out of bounds.
 
Note
It must be remembered that in C++ (as well as in Python, JavaScript, PHP) when using the logical connective AND (&&), if the first part is false , then the second part is not checked.

For example:
condition a = 0 && b != 0 when a = 5, the first part of a = 0 is false, so the second part of b != 0 will not be checked by the compiler.

Problem

In the given array, you need to find the value of the element equal to the value XX is entered from the keyboard. Add a condition to the program so that it solves the problem. Numbering of elements starts with zero.

If there is no such element, the program should output Not found.