Write a C function to search a number in the given list of
numbers. donot use printf and scanf
Answers were Sorted based on User's Feedback
Answer / dinakarangct
the below function return the index value if present else
return a index which is equal to n;
int search(int n,int data,int *a)
{
int i;
for(i=0;i<n;i++)
if(a[i]==data)
return i;
}
Is This Answer Correct ? | 10 Yes | 4 No |
Answer / bharghavi
void search(int data)
{
for(int i=0;i<n;i++)
{
if(a[i]==data)
break;
}
}
Is This Answer Correct ? | 12 Yes | 10 No |
Answer / rohitakhilesh
void search(int *a,int data,int n)
{
for(int i=0;i<n;i++)
{
if(a[i]==data)
break;
}
}
Is This Answer Correct ? | 9 Yes | 7 No |
Answer / dhairyashil
void search(int data)
{
for(int i=0;i<n;i++)
{
if(a[i]==data)
break;
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / peter
Once the list of integer was sorted, u can use binary search.
Is This Answer Correct ? | 1 Yes | 6 No |
What is your nationality?
/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }
How to reverse a String without using C functions ?
33 Answers Matrix, TCS, Wipro,
What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;
const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above
why java is platform independent?
{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }
main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }
Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines
Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)
3 Answers Disney, Google, ZS Associates,
what is variable length argument list?