Find the maximum product of three numbers in an array?
Eg. 9,5,1,2,3
Max product= 9*5*3= 135
The array can hav negative numbers also..
Answer Posted / sathish
1)Sort the array in descending order.
2)Multiply for required number of indices.
CODE:
int mul=1;
for(i=0;i<3;i++)
{
mul=mul*a[i];
}
cout<<mul;
| Is This Answer Correct ? | 11 Yes | 16 No |
Post New Answer View All Answers
Write a simple encryption program using string function which apply the substitution method.
Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++
write a program to perform generic sort in arrays?
how to diplay a external image of output on winxp by using c & c++,
Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).
How to swap two ASCII numbers?
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 Small C++ Class to Transform Any Static Control into a Hyperlink Control?
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150
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)
write a program that can LOCATE and INSERT elements in array using c++ programming languages.
develop a program to calculate and print body mass index for 200 employees
3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...
write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used