Searching a number using Arrays

#include<iostream>
using namespace std;
int sum=0,ar[10],value,found=0;
int main(){

for(int x=0;x<10;x++){
cout<<"enter value "<<x+1<<"   "<<endl;
cin>>ar[x];

}

cout<<"enter value that you want to search "<<endl;
cin>>value;

for(int x=0;x<10;x++){
if(value==ar[x]){
cout<<" the search element is found at position at position  ["<<x<<"]"<< endl;
found++;
}
}

if(found<1){
cout<<"sorry we could not find "<<value<<"in any place at array "<<endl;
}
}





Previous
Next Post »

Comments:

Disqus Shortname