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


Please Help Members By Posting Answers For Below Questions

program explaining feautures of c++

2050


How can virtual functions in c++ be implemented?

698


Is c++ still in demand?

735


what is data abstraction in C++?

742


What is size of string in c++?

652






what is c++

1882


What are the sizes and ranges of the basic c++ data types?

683


What is meant by forward referencing and when should it be used?

655


How many characters are recognized by ANSI C++?

1016


What do you mean by translation unit?

698


Differentiate between declaration and definition.

680


What is the sequence of destruction of local objects?

632


What does std mean in c++?

698


What are c++ variables?

626


State two differences between C and C++.

706