Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

wite a programme in c to linear search a data using flag and
without using flags?

Answer Posted / st0le

int linearSearch(int a[],int ub,int key)
{
for(int i=0;i<n;i++)
if(a[i] == key) return i;
return -1; //not found!
}

int linearSearch(int a[],int ub,int key)
{
int flag = 0;
for(int i=0;i<n;i++)
if(a[i] == key)
{ flag = 1; break; }

return (flag)? i:-1; //not found!
}

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why c language is called c?

1025


How do we print only part of a string in c?

1032


Define C in your own Language.

1089


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

1122


What are the advantages of Macro over function?

2032


What is identifiers in c with examples?

1189


I need previous papers of CSC.......plz help out by posting them.......

2298


With the help of using classes, write a program to add two numbers.

1049


Which built-in library function can be used to match a patter from the string?

1308


What is the advantage of a random access file?

1208


Explain what are global variables and explain how do you declare them?

1177


Is anything faster than c?

1018


Why we use break in c?

1025


What is zero based addressing?

1184


to find the closest pair

2326