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
write a c program in such a way that if we enter the today date the output should be next day's date.
What is the difference between array_name and &array_name?
Explain how can I right-justify a string?
What are categories used for in c?
What are preprocessor directives in c?
FILE PROGRAMMING
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
the question is that what you have been doing all these periods (one year gap)
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
In which layer of the network datastructure format change is done
Can you please explain the difference between malloc() and calloc() function?
What is return in c programming?
What are pointers in C? Give an example where to illustrate their significance.
Is c is a procedural language?
Why is main function so important?