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
How will you find a duplicate number in a array without negating the nos ?
What is the use of define in c?
What does c mean in standard form?
Why should I use standard library functions instead of writing my own?
What is c system32 taskhostw exe?
What library is sizeof in c?
Is c++ based on c?
What is the difference between char array and char pointer?
What is a volatile keyword in c?
What is the meaning of c in c language?
I have seen function declarations that look like this
Difference between constant pointer and pointer to a constant.
Explain what are compound statements?
Differentiate call by value and call by reference?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion