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()

                {

                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 "<

                                }

                }

 

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
A PROGRAM TO CALCULATE AREA OF TRIANGLE

When you are designing a generic class to have or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or

Make a list of functions that are standard in C++. You must include each of the following for each function: Name of function Its parameters Data type it returns

A: C++, unlike only about every other language with exceptions, is extremely accomodating while it comes to what you can throw. Actually, you can throw anything you akin to. That b

Build a program that calculates a discount for items based on quantity bought each item is $99.99 Ask user to enter the quantity of the items Get the quantity of items from the u

make a marksheet of 2 student with 5 subject

HWID Spoofer for Windows 7, 8 x64 Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program a

How would I make a maze in C++? I would prefer to use the recursion maze generation algorithm if possible, thanks!


how to fill the blank spaces in the board of 4*4 matrix with the minimum of 4 colors and the condition is the adjacent element should not have the same colour