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
Can you write a function similar to printf()?
Why do we need runtime polymorphism in c++?
What is a volatile variable in c++?
Explain virtual class and friend class.
Write about the use of the virtual destructor?
Is java a c++?
What are punctuators in c++?
How can I learn dev c++ programming?
What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00
What is an undefined reference/unresolved external symbol error and how do I fix it?
What is meant by const_cast?
What are guid?
What does new in c++ do?
Is c++ vector a linked list?
How can virtual functions in c++ be implemented?