liniera search in array
#include <iostream>
using namespace std;
bool search (char listOfVowels[], int size,int key){
for (int i = 0; i < size; i++)
{
if (listOfVowels[i]==key)
{
return 1 ;
}
}
return 0;
};
int main(){
char listOfVowels[5]={'a','e','i','o','u'};
char key;
cout<<"plz enter the key to search of : ";
cin>>key;
char found = search(listOfVowels,5,key);
if (found)
{
cout<<"yes it is present! ";
}
else{
cout<<"No it is not preset!";
}
cout<<found;
}
Comments
Post a Comment