Write a program that read 2o numbers in and array and
output the second largest number. Can anybody help??
Answer Posted / sujeet pardeshi
int k;
for(i=0;i<2;i++)
{
max=0;
for(j=n;j>=i;j--)
{
if(a[j]>max)
{
max=a[j];
k=j;
}
}
swap(a[i],a[k]);
}
printf("2nd highest no is:%d",max);
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
Explain the difference between using macro and inline functions?
How is data hiding achieved in c++?
What is the use of endl in c++?
How can I learn c++ easily?
What is the basic structure of c++ program?
What is the purpose of extern storage specifier?
What is a constructor and how is it called?
Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).
Why do we use vector in c++?
Can recursive program be written in C++?
Which programming language is best to learn first?
Eplain extern keyword?
What is the difference between public, private, and protected access?
How can you tell what shell you are running on unix system?
What is lvalue?