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

program to find the roots of a quadratic equation

14 Answers   College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,


main() { int c=- -2; printf("c=%d",c); }

1 Answers   TCS,


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

9 Answers   Microsoft,


main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4

2 Answers   HCL,


main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

5 Answers   HCL,






#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

1 Answers  


void main() { int i=i++,j=j++,k=k++; printf(ā€œ%d%d%dā€,i,j,k); }

1 Answers  


main() { int i=5; printf("%d",++i++); }

1 Answers  


Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

1 Answers  


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }

2 Answers   Broadridge,


Categories