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 |
plz tell me the solution.......... in c language program guess any one number from 1 to 50 and tell that number within 8 asking question in yes or no...............
{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above
How we print the table of 3 using for loop in c programing?
Is it possible to type a name in command line without ant quotes?
how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!
main() { int i=400,j=300; printf("%d..%d"); }
main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };