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 is lazy initialization in c++?
What is the use of data hiding?
What is decltype c++?
What is virtual table?
What is the difference between multiple and multilevel inheritance in c++?
What is encapsulation in c++?
Explain how a pointer to function can be declared in C++?
How are the features of c++ different from c?
how can i access a direct (absolute, not the offset) memory
address?
here is what i tried:
wrote a program that ask's for an address from the user,
creates a FAR pointer to that adress and shows it. then the
user can increment/decrement the value in that address by
pressing p(inc+) and m(dec-).
NOW, i compiled that program and opened it twice (in 2
different windows) and gave twice the same address to it.
now look what happen - if i change the value in
one "window" of the program, it DOES NOT change in the
other! even if they point to the same address in the memory!
here is the code snippet:
//------------------------------------------------------
#include How is static data member similar to a global variable? Is string an object in c++? Define private, protected and public access control. If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first
a) 1
b) 5
c) 3 Is c++ an oop? What is the difference between reference and pointer?