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 test design and test case design?
write a proram to reverse the string using switch case?
What is property type c?
Explain how can you avoid including a header more than once?
What are qualifiers and modifiers c?
What are file streams?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
Define VARIABLE?
Write a program to check prime number in c programming?
What does c mean?
Is flag a keyword in c?
Explain can you assign a different address to an array tag?
What is a buffer in c?
write a program to print largest number of each row of a 2D array