diff --git a/Searching/linearsearch.cpp b/Searching/linearsearch.cpp new file mode 100644 index 0000000..28d0e58 --- /dev/null +++ b/Searching/linearsearch.cpp @@ -0,0 +1,33 @@ +#include +#include +using namespace std; +int main() +{ + int myarray[10] = {21,43,23,54,75,13,5,8,25,10}; + int key,loc; + cout<<"The input array is"<>key; + for (int i = 0; i< 10; i++) + { + if(myarray[i] == key) + { + loc = i+1; + break; + } + else + loc = 0; + } + if(loc != 0) + { + cout<<"Key found at position "<