Module: Linear and binary search for elements in an array


Problem

2/7

Linear search - 1

Theory Click to read/hide

Setpoint search algorithm
In order to find an element equal to the given value X, it is necessary to look through all the elements of the array from the first to the last. As soon as an element equal to the given value X is found, the search must be completed and display the result.

The easiest way to implement this algorithm is with the while loop operator. Try adding a condition yourself in the while operator.

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.