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

What are the different types of pointers used in c language?

622


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3670


How can I access an I o board directly?

634


Are the outer parentheses in return statements really optional?

584


Explain two-dimensional array.

637






Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

636


Explain what is a pragma?

605


What are the two types of structure?

590


What is the use of getch ()?

648


What do you know about the use of bit field?

620


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1911


write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34

1645


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

1917


What is the best organizational structure?

650


how many key words availabel in c a) 28 b) 31 c) 32

641