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

Answers were Sorted based on User's Feedback



write a program to find the largest and second largest integer from an array..

Answer / 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

write a program to find the largest and second largest integer from an array..

Answer / mahesh

use bubble sort next to this, print last n second from last..

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

What is time complexity c?

0 Answers  


Write a program in C to convert date displayed in gregorian to julian date

0 Answers   HCL, Wipro,


a memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed: s="Etrance" l=strlen(s); what is the value of l ? a.20 b.8 c.9 d.21

4 Answers   TCS,


"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above

0 Answers  


i want to know the procedure of qualcomm for getting a job through offcampus

0 Answers   HCL,


main() { int i; printf("%d",i^i); }

1 Answers  


Write a program which returns the first non repetitive character in the string?

0 Answers   Expedia,


struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??

9 Answers   Verifone,


Why we use break in c?

0 Answers  


What is alloca() and why is its use discouraged?

1 Answers  


Explain how can a program be made to print the line number where an error occurs?

0 Answers  


What is optimization in c?

0 Answers  


Categories