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
What are the different types of pointers used in c language?
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
How can I access an I o board directly?
Are the outer parentheses in return statements really optional?
Explain two-dimensional array.
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.?
Explain what is a pragma?
What are the two types of structure?
What is the use of getch ()?
What do you know about the use of bit field?
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 .
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
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What is the best organizational structure?
how many key words availabel in c a) 28 b) 31 c) 32