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


Please Help Members By Posting Answers For Below Questions

Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

1524


Can the sizeof operator be used to tell the size of an array passed to a function?

622


One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2162


How can you check to see whether a symbol is defined?

596


Explain continue keyword in c

590






what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1260


Explain what are run-time errors?

612


how many errors in c explain deply

1633


How is pointer initialized in c?

589


What is static memory allocation? Explain

634


Explain what is the difference between functions abs() and fabs()?

626


What is else if ladder?

614


How to establish connection with oracle database software from c language?

1679


What is the significance of an algorithm to C programming?

598


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2339