Answer Posted / pavan_mustyala
/**************************
Locates Search Element in the array and returns it's
position. If not found returns -1(Invalid)
**************************/
int locateElement(int *arr, int searchElement, int
arraySize)
{
int i = -1;// Invalid Id
for(i = 0; i < arraySize; i++)
{
if(arr[i] == searchElement)
{
return i; // Element found at this index in the array
}
}
return -1; // Search Element not found in the array
}
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
write a program that reads a series of strings and prints only those strings begging with letter "b"
output for printf("printf");
How to Split Strings with Regex in Managed C++ Applications?
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }
solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)
How can I Draw an ellipse in 3d space and color it by using graph3d?
Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).
Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.
Code for Method of Handling Factorials of Any Size?
1+1/2!+1/3!+...+1/n!
Code for Two Classes for Doing Gzip in Memory?
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n
U hv to enter a range from a and b and search hw many no. of times a pattern n. occurs between the range a and b. Eg :i/p:enter range :0 100 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 0 to 100:1 Eg :i/p:enter range :100 1000 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 100 to 1000: (in this 13,113,131,132,133…139,213,313,…913 all these will be counted)