Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

linear search in c languge

#include <stdio.h>
int main()
{
    int n;
    printf("enter array limit :
");
    scanf("%d", &n);
    printf("enter your array elements :
");
    int a[n], i;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    printf("your array is :
");
    for (i = 0; i < n; i++)
    {
        printf("%d	", a[i]);
    }
    printf("
");
    printf("enter element that you want to search :
");
    int v;
    scanf("%d", &v);
    for (i = 0; i < n; i++)
    {
        if (a[i] == v)
        {
            return printf("your element is match in this array inwhich element no = %d", i + 1);
        }
    }
   return printf("your enter element is't match...");
}
 
PREVIOUS NEXT
Tagged: #linear #search #languge
ADD COMMENT
Topic
Name
4+4 =