-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayInterSch.cpp
40 lines (33 loc) · 1.01 KB
/
ArrayInterSch.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<iostream>
using std::cout;
using std::string;
using std::cin;
using std::endl;
int mysearch(string searchs[], int size, string elements);
int main( ){
string inputs;
int index;
cout<<"Enter here - \n";
cin>>inputs;
string searchList[] = {"Apple", "Bravo", "Charlie", "Delta", "Echo"};
int size = sizeof(searchList)/sizeof(searchList[0]);
for(int i = 0; i <size; i++){
cout<<searchList[i]<<'\n';
}
index = mysearch(searchList, size, inputs);
if(index!= -1){
cout<<"Your input "<<inputs<< " your index "<<index;
}
else{
cout<<" Entered is not in list ";
}
return 0;
}
int mysearch(string searchs[], int size, string elements){
for (int i =0 ; i<size ; i ++){
if(searchs[i]== elements){
return i;
}
}
return -1;
}