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

find A^B using Recursive function

2 Answers  


main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

1 Answers   TCS,


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

4 Answers  


#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }

1 Answers  






which function is used to clear the buffer stream on gcc? for example: I wrote following code on gcc #include<stdio.h> int main(void) { char ch; int a,b; printf("\nenter two numbers:\t"); scanf("%d%d",&a,&b); printf("enter number is %d and %d",a,b); printf("\nentercharacter:\t"); scanf("%c",&ch); printf("enter character is %c",ch); return 0; } in above progarm ch could not be scan. why?plz tell me solution.

2 Answers  


write a c-program to display the time using FOR loop

3 Answers   HCL,


Give a one-line C expression to test whether a number is a power of 2.

10 Answers   Microsoft,


How we print the table of 2 using for loop in c programing?

14 Answers   HCL, Wipro,


main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }

1 Answers  


int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could anyone explain this to me.

2 Answers   Bosch, eInfochips, HCL, IHCL,


main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  


Categories