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 to find the largest and second largest
integer from an array

Answer Posted / manish gupta

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],x,y,c;
for (x=0;x<5;x++)
{
printf("enter any number");
scanf("%d",&a[x]);
}
for (x=0;x<5;x++)
{
for (y=0;y<4;y++)
{
if (a[y]>a[y+1])
{
c=a[y];
a[y]=a[y+1];
a[y+1]=c;
}
}
}
printf("\nlargest no:-%d",a[y]);
printf("\nsecond largest no:-%d",a[y-1]);
getch();
}

Is This Answer Correct ?    17 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do some versions of toupper act strangely if given an upper-case letter?

1078


What is void c?

1094


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

1282


Is boolean a datatype in c?

1069


is it possible to create your own header files?

1107


What is the use of structure padding in c?

1072


What are data structures in c and how to use them?

1173


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

3322


What is the purpose of & in scanf?

1078


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

1088


Where define directive used?

1097


What are run-time errors?

1120


Do pointers store the address of value or the actual value of a variable?

1082


How can I avoid the abort, retry, fail messages?

1138


What is volatile, register definition in C

1109