Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int arr[100];
- int i, loc=0,item, n, k=1;
- cout<<"Enter the value of range: ";
- cin>>n;
- cout<<"Enter the values: "<<endl;
- for(i=1; i<=n; i++)
- {
- cin>>arr[i];
- }
- /*cout<<"The value of set is: ";
- for(i=0; i<n; i++)
- {
- cout<<arr[i];
- }*/
- cout<<"Enter the value for searching: "<<endl;
- cin>>item;
- while(k<=n && loc==0)
- {
- if(item==arr[k])
- {
- loc=k;
- }
- k++;
- }
- if (loc==0)
- cout<<"The value is not found."<<endl;
- else
- cout<<"The value is number "<<loc<<endl;
- }
Add Comment
Please, Sign In to add comment