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
What is a pdb file?
What is pointer in c++ with example?
What is the error in the code below and how should it be corrected?
What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator?
What's the most powerful programming language?
What is c++ similar to?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
How to tokenize a string in c++?
Difference between inline functions and macros?
Why c++ is better than c language?
Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.
How do you print a string on the printer?
Define anonymous class.
Why iomanip is used in c++?
What is the difference between structures and unions?