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 progarm to find the length of string using switch case?
What are file streams?
What are identifiers c?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
Who developed c language and when?
How can I swap two values without using a temporary?
What is the use of header files?
List some applications of c programming language?
Are comments included during the compilation stage and placed in the EXE file as well?
What are # preprocessor operator in c?
Explain what is the difference between a string and an array?
Write a simple code fragment that will check if a number is positive or negative.
What is union in c?
What does void main () mean?