Write a program that read 2o numbers in and array and
output the second largest number. Can anybody help??
Answer Posted / ajit
#include<stdio.h>
void main()
{
int a[20],i,j,temp;
printf("enter the 20 values\n");
for(i=0;i<20;i++)
scanf("%d",&a[i]);
for(i=0;i<20;i++)
{
for(j=i+1;j<20;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("the second largest number is %d\n",a[18]);
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Which is the best c++ software?
What are disadvantages of pointers?
How does a copy constructor differs from an overloaded assignment operator?
What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.
What are static variables?
Explain the purpose of the keyword volatile.
What is a static element?
What do you understand by a pure virtual member function?
Explain stack & heap objects?
What is the auto keyword good for in c++?
Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?
What is endianness?
What is std namespace in c++?
What it is and how it might be called (2 methods).
Difference between delete and free.