Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Can you write a function similar to printf()?

1138


Why do we need runtime polymorphism in c++?

1034


What is a volatile variable in c++?

1478


Explain virtual class and friend class.

1060


Write about the use of the virtual destructor?

1009


Is java a c++?

1053


What are punctuators in c++?

1171


How can I learn dev c++ programming?

1065


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

1075


What is an undefined reference/unresolved external symbol error and how do I fix it?

1132


What is meant by const_cast?

1132


What are guid?

1253


What does new in c++ do?

1029


Is c++ vector a linked list?

1004


How can virtual functions in c++ be implemented?

1139