program of linear searching a list in an array.

// it a program to search the element in an array in sequence.
/* for example you can search the element in an array or list
firstly you can enter the element you can search and this compare
the element one by one at the starting point*/
#include<stdio.h>
int main()
{
    int list[10]={12,5,4,6,7,9,10,2,8,0};
    int search ,i;
    printf("Enter the element you can search in the list:\n");
    scanf("%d", &search);
    for(i=0;i<10;i++)
    {
        if(search==list[i])
        {
            printf("Search successful at the position %d",i+1);
            break;
        }
    }
    if(i==10)
    {
        printf("Invalid search!");
    }
    return 0;

output
Enter the element you can search in the list:
7
Search successful at the position 5
  ******** Thank you! hopeful you can know about linear searching .
any doubt you can comment. ********

Comments

Popular posts from this blog

18 Amazing programs in C.