Answer Posted / vinod, bangalore, india
int Second_Max(int* numbers, int Lenght)
{
int Max, Sec_Max, index;
Max = Sec_Max = numbers[0];
for(index=0; (index<Lenght) &&(Max == Sec_Max);
index++)
{
if(Max > numbers[index])
Sec_Max = numbers[index];
else
Max = numbers[index];
}
if(index == Lenght)
{
printf("Array contain simillar data and the
data is = %d \n", Max);
return false;
}
for(index =0; index < Lenght; index++)
{
if(numbers[index] > Max)
{
Sec_Max = Max;
Max = numbers[index];
}
if((numbers[index] < Max) && (numbers
[index] > Sec_Max))
{
Sec_Max = numbers[index];
}
}
return Sec_Max;
}
Is This Answer Correct ? | 2 Yes | 7 No |
Post New Answer View All Answers
What does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)
Does c++ support multilevel and multiple inheritances?
What is namespace & why it is used in c++?
What is ios flag in c++?
Is c++ a float?
What is pure virtual function?
If a function doesn’t return a value, how do you declare the function?
I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.
How a modifier is similar to mutator?
What can I safely assume about the initial values of variables which are not explicitly initialized?
What is problem with overriding functions?
How many standards of c++ are there?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
What is a wchar_t in c++?
Difference between Abstraction and encapsulation in C++?