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 |
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().
Write a program to model an exploding firecracker in the xy plane using a particle system
How can i find first 5 natural Numbers without using any loop in c language????????
main() { char a[4]="HELLO"; printf("%s",a); }
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']
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.
void main () { int x = 10; printf ("x = %d, y = %d", x,--x++); } a. 10, 10 b. 10, 9 c. 10, 11 d. none of the above
can u give me the c codings for converting a string into the hexa decimal form......
main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }