From aff9b2fe84811b22f0cda301dd180861302989bc Mon Sep 17 00:00:00 2001 From: tarushirastogi <108577219+tarushirastogi@users.noreply.github.com> Date: Sun, 30 Oct 2022 18:03:21 +0530 Subject: [PATCH] Create Linear_Search.cpp Added Linear Search Algorithm. --- Searching Algorithms/Linear_Search.cpp | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Searching Algorithms/Linear_Search.cpp diff --git a/Searching Algorithms/Linear_Search.cpp b/Searching Algorithms/Linear_Search.cpp new file mode 100644 index 0000000..7c9b031 --- /dev/null +++ b/Searching Algorithms/Linear_Search.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; +int linear_search(int arr[],int key,int size){ + for(int i=0;i>n; + for(int i=0;i>arr[i]; + } + cout<<"Enter the element to search in the array"<>key; + pos= linear_search(arr,key,n); + if(pos==-1){ + cout<<"Element not found"<