Linear search in array - c program, C/C++ Programming

Linear search in array - C program:

Write a program in c to define a linear search in array.

void main()



                int a[100] , ch , n;

                cout<<"enter the nit for the array : ";


                for (int i=0;i


                                cout<<"enter element "<



                  Cout<< "Linear search:"

                        lsearch (a,n);


                } //main




void lsearch (int a[100] , int n)


                int i,ele,found=0,pos=-1;

                cout<<"enter the element to be searched : ";


                for (i=0;i


                                if (a[i] == ele)


                                                found = 1 ;

                                                pos = i;



                if (found ==-1)


                                cout<<"element not found";




                                cout<<"element found at "<




Posted Date: 10/19/2012 3:11:36 AM | Location : United States

Related Discussions:- Linear search in array - c program, Assignment Help, Ask Question on Linear search in array - c program, Get Answer, Expert's Help, Linear search in array - c program Discussions

Write discussion on Linear search in array - c program
Your posts are moderated
Related Questions
salotion of programes

write a program that can accept numbers and perform all the four arithmetic operation

Write a program that keeps record of football results. Program stores following information about each match: Description Type and/or size name of home team max. 25 characters name

Explain Register Variable Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calcula

Define a structure to store roll no, name and marks of a student. b) Using the structure of Q2. a), above write a ''C'' program to create a file "student.dat". There must be one r

Changing Field width The printf() and scanf() functions from the standard library, use width specifier for controlling the width of its output . Similarly, the ostream class al

a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b.   #include float start_point, /* G

Prepare Windows Shell Extension Project Description: Skills required are C++ Programming, Windows Desktop, Windows API