this is code for linear search in 10 array table btw it has to be in do-while or while loop not for loop.
#include <stdio.h>
#include <stdlib.h>
int
search(int t[], int x, int n)
{
    int i;
    i == 0;
    do {
        i = i + 1;
    } while ((t[i] != x) || (n > i));
    if (t[i] == x) {
        printf("index=%d", i + 1);
    }
    else {
        printf("element not found");
    }
}
int
main()
{
    int t[10];
    int x, i;
    printf("enter x: ");
    scanf("%d", &x);
    for (i = 0; i < 10; i++) {
        printf("enter table element : ");
        scanf("%d", &t[i]);
    }
    search(t, x, 10);
    return 0;
}
i excepted to get the index of the specified number (x) in the table but the problem is that results are wrong (it show 3 digit number) and sometimes won't show anything at all
 
     
    