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 |
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }
main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }
#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }
Find your day from your DOB?
15 Answers Accenture, Microsoft,
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.
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,
main() { extern int i; i=20; printf("%d",sizeof(i)); }
Write a function to find the depth of a binary tree.
13 Answers Adobe, Amazon, EFI, Imagination Technologies,
void main() { int i=5; printf("%d",i++ + ++i); }
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }