SHARE
TWEET

linear search

a guest Jun 16th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. int main()
  3. {
  4.  
  5.     int arr[10],i,key;
  6.     printf("Enter number of elements\n");
  7.     for(i=0;i<10;i++){
  8.  
  9.         scanf("%d",&arr[i]);
  10.  
  11.  
  12.     }
  13.     scanf("%d",&key);
  14.     for(i=0;i<10;i++){
  15.         if( key == arr[i]){
  16.  
  17.             printf("found\n");
  18.             return 0;
  19.         }
  20.     }
  21.  
  22.     printf(" Not found\n");
  23.  
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top