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
Why c language is called c?
How do we print only part of a string in c?
Define C in your own Language.
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
What are the advantages of Macro over function?
What is identifiers in c with examples?
I need previous papers of CSC.......plz help out by posting them.......
With the help of using classes, write a program to add two numbers.
Which built-in library function can be used to match a patter from the string?
What is the advantage of a random access file?
Explain what are global variables and explain how do you declare them?
Is anything faster than c?
Why we use break in c?
What is zero based addressing?
to find the closest pair