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

What is variable initialization and why is it important?

1341


How can I call fortran?

1099


How is a structure member accessed?

1189


Explain how can I pad a string to a known length?

1249


Explain what is wrong with this statement? Myname = ?robin?;

1641


What are identifiers and keywords in c?

1200


What are the properties of union in c?

1111


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2574


How can I read data from data files with particular formats?

1093


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1227


How do you list a file’s date and time?

1110


Does sprintf put null character?

1094


Why is c not oop?

1038


Explain the advantages of using macro in c language?

1048


What are the types of variables in c?

1086