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

Popular posts from this blog

swapping the alternate values in given array's element ! 17/11/2022

c++ basic question

Learning stage | c++ programs