Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int arrSize, value;
- bool found=false ;
- cout<<"Enter array size: ";
- cin>>arrSize;
- int arr[arrSize];
- for(int i=0 ; i<arrSize ; i++)
- {
- cout<<"Enter value #"<<i+1<<" : ";
- cin>>arr[i];
- }
- cout<<"\n\n";
- cout<<"Enter search value: ";
- cin>>value;
- cout<<"\n";
- for(int i=0 ; i<arrSize ; i++)
- {
- if(arr[i]==value)
- {
- found=true;
- cout<<"Value "<<value<<" is at index #"<<i+1<<endl;
- }
- }
- if(!found)cout<<"Cannot find the value "<<value<<" in the array."<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement