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

Assignment Help:

Linear search in array - C program:

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

void main()

                {

                clrscr();

                int a[100] , ch , n;

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

                cin>>n;

                for (int i=0;i

                                {

                                cout<<"enter element "<

                                cin>>a[i];

                                }

                  Cout<< "Linear search:"

                        lsearch (a,n);

                getch();

                } //main

 

 

 

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

                {

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

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

                cin>>ele;

                for (i=0;i

                                {

                                if (a[i] == ele)

                                                {

                                                found = 1 ;

                                                pos = i;

                                                }

                                }

                if (found ==-1)

                                {

                                cout<<"element not found";

                                }

                else

                                {

                                cout<<"element found at "<

                                }

                }

 


Related Discussions:- Linear search in array - c program

Vogels approximation transportation problem, Vogels approximation transport...

Vogels approximation transportation problem in c language source code

What difficulty does the namespace feature solve out?, A: Multiple provider...

A: Multiple providers of libraries might employ common global identifiers causing a name collision whereas an application attempt to link with two or more such libraries. The names

Implement a algorithm to verify if the link list , Implement a Algorithm to...

Implement a Algorithm to verify if the link list is in Ascending order? A: template bool linklist::isAscending() const{ nodeptr ptr = head; while (ptr->_next)

Friend function, Ask question #Minimum 100 what is friend function is used ...

Ask question #Minimum 100 what is friend function is used in c++

Member dereferencing operators, M em b e r d e r e f e r e n c ...

M em b e r d e r e f e r e n c i ng o p e r a t o r s: T h e s e op e r a t o r s w i l l b e d i s c u s s e d l a t

Loop statement, write a c++ program to accept 3 numbers and find the larges...

write a c++ program to accept 3 numbers and find the largest of 3 numbers

Determining the monthly payment on a mortgage loan, The following is the fo...

The following is the formula that can be used to complete that calculation: Monthly Payment = Monthly Interest Rate / (1 - (1 + Monthly Interest Rate) -Payment Interval )) *

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd