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

What is a syntax in c++?

611


Explain what you mean by a pointer.

636


What are the four main data types?

590


Can we specify variable field width in a scanf() format string? If possible how?

666


Can you explicitly call a destructor on a local variable?

604






What is DlgProc?

604


What is a manipulator in c++?

717


What is & in c++ function?

597


How do you decide which integer type to use?

579


What is the operator in c++?

636


Is turbo c++ free?

627


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1870


What is == in programming?

621


What is the use of structure in c++?

557


What are the syntactic rules to be avoid ambiguity in multiple inheritance?

636