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

Dont ansi function prototypes render lint obsolete?

0 Answers  


Write any data structure program (stack implementation)

1 Answers   HTC,


plz answer.... write a program that reads line (using getline) e.g."345", converts each line to an integer using "atoi" and computes the average of all the numbers read. also compute the standard deviation.

1 Answers  


write a program for fibonaci series by using while loop in c?

2 Answers  


Find greatest of two numbers using macro

4 Answers   Bosch, Siemens,






Where are the auto variables stored?

0 Answers   TISL,


Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ?

8 Answers   Mascot, TCS,


what is ur strangth & weekness

0 Answers   Cognizant, LG Soft, NetEnrich,


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

0 Answers  


What are the restrictions of a modulus operator?

0 Answers  


what are non standard function in c

0 Answers  


How will you declare an array of three function pointers where each function receives two ints and returns a float?

0 Answers   TISL,


Categories