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

struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; } a. Runtime error. b. Compile error. Illegal syntax c. Gets into Infinite loop d. None of the above

4 Answers   HCL, LG,


# include<stdio.h> aaa() { printf("hi"); } bbb(){ printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); }

1 Answers  


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

0 Answers  






#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


why java is platform independent?

13 Answers   Wipro,


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 Answers  


Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.

3 Answers   Wipro,


Question: We would like to design and implement a programming solution to the reader-writer problem using semaphores in C language under UNIX. We assume that we have three readers and two writers processes that would run concurrently. A writer is to update (write) into one memory location (let’s say a variable of type integer named temp initialized to 0). In the other hand, a reader is to read the content of temp and display its content on the screen in a formatted output. One writer can access the shared data exclusively without the presence of other writer or any reader, whereas, a reader may access the shared memory for reading with the presence of other readers (but not writers).

1 Answers  


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


Categories