Tuesday, 19 December 2017

TO IMPLEMENT LINEAR SEARCH

In this blog let us see how to implement a Linear Search in an array-



Sample output for the above program-
  • When user searches for value present in the array-


  • When the value searched is present at multiple positions-


  • When user searches for value NOT present in the array-


A brief explanation of the code-
  1. First we will take the size of the array as input.
  2. Then we will ask the user to enter the elements of the array.
  3. Then we will let user to enter a value that needs to be searched "find".
  4. Using 'for' loop we will run through the entire array and for each element 'if' equal to "find" we will display that particular element.

For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.








No comments:

Post a Comment