Search a Data Using Linear Search

This post content:-
Algorithm
Flowchart
C code
Output
Pdf notes

Algorithm :-
Step 1:- start.
Step 2:- declare an array.
Step 3:- declare variable and assign size of array to it.
(int size = sizeof(arr)/sizeof(int);)
Step 4:- give the value to find in the array.
Step 5:- make the function for linear search
    for(int i= 0;i<=size;i++)
    {
        if(arr[i]==element)
        {
          return i;
        }
    }
     return -1;
}(End of function)
Step 6:- assign output to the variable result.
Step 7:- print result.
Step 8:- end.


Flowchart:-
C code:-
Output:-
Try it yourself:- online c compiler

Comments

Popular posts from this blog

Develop a program to print values of variable and their addresses.

Develop a c program to find the sum of all elements stored in a given array using a pointer.