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 dll entry point?
What is c++ map?
Does dev c++ support c++ 11?
What is function prototyping?
What is the role of copy constructor in copying of thrown objects?
Is c++ fully object oriented?
What is the difference between the indirection operator and the address of oper-ator?
Describe protected access specifiers?
How can you link a c++ program to c functions?
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
write a programme to get a character and thier ASCII value
What is jump statement in C++?
What is a forward referencing and when should it be used?
Write a program to interchange 2 variables without using the third one.
What is else syntax in c++?