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

Which is the best c++ software?

1056


What are disadvantages of pointers?

1002


How does a copy constructor differs from an overloaded assignment operator?

988


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

1028


What are static variables?

1098


Explain the purpose of the keyword volatile.

1121


What is a static element?

1032


What do you understand by a pure virtual member function?

959


Explain stack & heap objects?

1012


What is the auto keyword good for in c++?

1141


Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?

1033


What is endianness?

1055


What is std namespace in c++?

1141


What it is and how it might be called (2 methods).

1128


Difference between delete and free.

1036