find second largest element in array w/o using sorting
techniques? use onle one for loop.
Answer Posted / sazzadcsedu
int max,secMax;
int A[100];
if(A[0]>A[1])
{
max=A[0];
secMax=A[1];
}
else
{
max=A[1];
secMax=A[0];
}
for(i=2;i<=length of Array;i++)
{
if (A[i]>max )
{
secMax=max;
max=A[i];
}
else if(array[i]>secMax)
{
secMax = A[i];
}
}
| Is This Answer Correct ? | 7 Yes | 7 No |
Post New Answer View All Answers
What would be an example of a structure analogous to structure c?
Explain goto?
What is "Duff's Device"?
Why main is used in c?
Explain what does it mean when a pointer is used in an if statement?
Does * p ++ increment p or what it points to?
How many keywords (reserve words) are in c?
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
Why void is used in c?
What is scanf_s in c?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
How does free() know explain how much memory to release?
What is #define size in c?
What is console in c language?
What are the advantages of using new operator as compared to the function malloc ()?