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
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.
Can the sizeof operator be used to tell the size of an array passed to a function?
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.
How can you check to see whether a symbol is defined?
Explain continue keyword in c
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
Explain what are run-time errors?
how many errors in c explain deply
How is pointer initialized in c?
What is static memory allocation? Explain
Explain what is the difference between functions abs() and fabs()?
What is else if ladder?
How to establish connection with oracle database software from c language?
What is the significance of an algorithm to C programming?
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.