Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define mx 5
- int search(int arr[],int x)
- {
- int i;
- for (i = 0; i < mx; i++)
- if (arr[i] == x)
- return i;
- return -1;
- }
- int main()
- {
- int arr[mx];
- for(int i=0;i<mx;i++)
- {
- cin>>arr[i];
- }
- int x;
- cout<<"Which Value you want to find"<<endl;
- cin>>x;
- int result=search(arr,x);
- if(result==-1)
- cout<<"Element is not present in array";
- else
- cout<<"Element is present at index"<<result;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement