Answer Posted / fish
int a1(int[] a)
{
int max1 = -1;
int max2 = -1;
for (int i=0; i<a.length; i++)
{
if (a[i] > max1)
{
max2 = max1;
max1 = a[i];
}
else if (a[i] != max1 && a[i] > max2)
max2 = a[i];
}
return max2;
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Why namespace is used in c++?
What you know about structures in C++?
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
What are keywords in c++?
What is auto type c++?
Does c++ have foreach?
What is the difference between a "copy constructor" and an "assignment operator" in C++?
Write a program to find the reverse Fibonacci series starting from N.
Can java be faster than c++?
Can you write a function similar to printf()?
Why is main function important?
int age=35; if(age>80) {Console.WriteLine("Boy you are old");} else {Console.WrieLine("That is a good age");}
What is lambda in c++?
Why do we use setw in c++?
What is the protected keyword used for?