Linear Search

What is meant by linear search of an array ?
Linear search means that you go through all the elements in the array in order until you find the element you search for, or reach the end of the array.
For example :
1
2
3
4
5
6
7
8
int num; //Your number, random

int array[100]; //Suppose it's random
bool bSuccess = false;

for(int i = 0;i < 100;i++)
if(num == array[i]){bSuccess = true;[...]} //Found !
if(!bSuccess){[...]} //Could not find the value 
Last edited on
thank yall for the answers :)
Topic archived. No new replies allowed.