From 474398726ff9dbc28ce74784a1e244b01d837bb0 Mon Sep 17 00:00:00 2001 From: suryakantdubalgunde <34354867+suryakantdubalgunde@users.noreply.github.com> Date: Sat, 8 Oct 2022 17:56:12 +0530 Subject: [PATCH] linear-search.cpp --- linear-search.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 linear-search.cpp diff --git a/linear-search.cpp b/linear-search.cpp new file mode 100644 index 000000000..1c745bbe1 --- /dev/null +++ b/linear-search.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 "<