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



Write a C function to search a number in the given list of numbers. donot use printf and scanf..

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

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

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

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

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

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

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

Write a C function to search a number in the given list of numbers. donot use printf and scanf..

Answer / peter

Once the list of integer was sorted, u can use binary search.

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More C Code Interview Questions

What is your nationality?

1 Answers   GoDB Tech,


/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }

4 Answers  


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) ;

1 Answers  


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

1 Answers   emc2, HCL,


why java is platform independent?

13 Answers   Wipro,


{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

4 Answers  


void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }

1 Answers  


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

0 Answers   IBM,


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?

2 Answers  


Categories