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 the difference between malloc() and calloc()?

1842


What is 2 d array in c?

1020


How do you initialize pointer variables?

1093


Add Two Numbers Without Using the Addition Operator

820


Can a function argument have default value?

1144


Where does the name "C" come from, anyway?

1164


What is external variable in c?

1057


please give me some tips for the placement in the TCS.

2108


WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.

2445


Why double pointer is used in c?

1035


the question is that what you have been doing all these periods (one year gap)

2078


In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

1203


What are multidimensional arrays?

1116


Do you know what are bitwise shift operators in c programming?

1099


write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

1927