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 |
WAP to display 1,2,3,4,5........N
#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }
main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }
Cau u say the output....?
main() { char not; not=!2; printf("%d",not); }
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']
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }
#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??
how to return a multiple value from a function?
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,
1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.
void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }