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

How will you find a duplicate number in a array without negating the nos ?

2082


What is the use of define in c?

1001


What does c mean in standard form?

1101


Why should I use standard library functions instead of writing my own?

1205


What is c system32 taskhostw exe?

975


What library is sizeof in c?

1036


Is c++ based on c?

1022


What is the difference between char array and char pointer?

982


What is a volatile keyword in c?

1112


What is the meaning of c in c language?

1073


I have seen function declarations that look like this

993


Difference between constant pointer and pointer to a constant.

1065


Explain what are compound statements?

994


Differentiate call by value and call by reference?

916


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2714