Answer Posted / jaldeep
int sec_max(int a[])
{
if(a[0]>a[1])
{
max=a[0]
sec_max=a[1]
}
else
{
max=a[1]
sec_max=a[0]
}
for(i=1;i<n-1;i++)
{
if (a[i]>sec_max && a[i]< max)
{
sec_max=a[i];
}
else if(a[i]>max)
{
sec_max=max;
max=a[i];
}
return sec_max;
}
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
What are the advantages of using a pointer? Define the operators that can be used with a pointer.
Explain about templates of C++.
what are the decision making statements in C++? Explain if statement with an example?
How would you find out if a linked-list is a cycle or not?
How much maximum can you allocate in a single call to malloc()?
What is meant by iomanip in c++?
Is it legal in c++ to overload operator++ so that it decrements a value in your class?
Why do we use vector in c++?
What do manipulators do?
How can we access protected and private members of a class?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
Which of the following is evaluated first: a) && b) || c) !
What are the differences between new and malloc?
What are the rules for naming an identifier?
Define Virtual function in C++.