alaminrifat

Linear Search in C++

Oct 12th, 2020 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main(){
  6.     int arr[10]={1,6,3,7,8,2,4,0,9};
  7.     cout<<"Enter Number you want to search :";
  8.     int n ; cin >>n;
  9.     for(int i = 0 ; i < 10 ; i++){
  10.         if(n==arr[i]){
  11.             cout<<n<<" found at index "<<i<<endl;
  12.             break;
  13.         }
  14.     }
  15. }
Add Comment
Please, Sign In to add comment