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-
- First we will take the size of the array as input.
- Then we will ask the user to enter the elements of the array.
- Then we will let user to enter a value that needs to be searched "find".
- 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