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
What is the difference between malloc() and calloc()?
What is 2 d array in c?
How do you initialize pointer variables?
Add Two Numbers Without Using the Addition Operator
Can a function argument have default value?
Where does the name "C" come from, anyway?
What is external variable in c?
please give me some tips for the placement in the TCS.
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
Why double pointer is used in c?
the question is that what you have been doing all these periods (one year gap)
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What are multidimensional arrays?
Do you know what are bitwise shift operators in c programming?
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...