From c56094516ad6859bce1d62e02f9b5094c0b9895c Mon Sep 17 00:00:00 2001 From: Saumyamani Bhardwaz <83209337+Saumyamani-Bhardwaz@users.noreply.github.com> Date: Sun, 31 Oct 2021 16:15:19 +0530 Subject: [PATCH] Create key.cpp --- key.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 key.cpp diff --git a/key.cpp b/key.cpp new file mode 100644 index 0000000..d9a2735 --- /dev/null +++ b/key.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +int main() +{ +int size = 10; +int array[size]; +for (int i = 0; i< size; i++) +{ +cout<< "Index " <> array[i]; +} +int key; +cout<< "\nEnter the number you want to search: "; +cin>>key; +int ele = -1; +for (int i = 0; i< size; i++) +{ +if (array[i] == key) +{ +ele = i; + +} +} +cout<< "\nThe index of number " << key << " is " <