//linear search by self
#include <stdio.h>

int main() {
    int a[50],i,n,key,loc=-1;
    printf("Enter size of array : ");
    scanf("%d ",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&a[i]);
    }
    printf("\nEntered elements are : ");
    for(i=0;i<n;i++){
        printf("%d ",i);
    }
    printf("\nEnter element you want to search : ");
    scanf("%d ",&key);
    for(i=0;i<n;i++){
        if (a[i]==key){
            loc=i+1;
        }
    }
    if(loc==-1){
        printf("\nElement not found");
    }else{
        printf("\nElement %d found at position %d",key,loc+1);
    }
    
    
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: