how can i search an element in an array
Answers were Sorted based on User's Feedback
Answer / pavan_mustyala
In C-Language, In general, we compare each element of the
array in a loop that iterates till the element is found.
This is called Linear search.
while(1)
{
// code here
if(element found)
break;
}
Here, execution time depends on the array size and position
of the element in the array.
For sorted arrays, we can use techniques such as binary
search using which execution is faster.
| Is This Answer Correct ? | 2 Yes | 0 No |
my $element = 'Whatever you are searching for' ;
if (grep {$_ eq $element} @TheArray) {
print "Element '$element' found!\n" ;
}
| Is This Answer Correct ? | 4 Yes | 9 No |
Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
2 Answers Mentor Graphics, Microsoft,
main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }
29 Answers IBM, TCS, UGC NET, Wipro,
Write a routine that prints out a 2-D array in spiral order
#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer
Write a C function to search a number in the given list of numbers. donot use printf and scanf
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcpy(a,b)); } a. “Hello” b. “Hello World” c. “HelloWorld” d. None of the above
4 Answers Corporate Society, HCL,
how to delete an element in an array
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']
void ( * abc( int, void ( *def) () ) ) ();
main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
how to return a multiple value from a function?