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
Why do some versions of toupper act strangely if given an upper-case letter?
What is void c?
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
Is boolean a datatype in c?
is it possible to create your own header files?
What is the use of structure padding in c?
What are data structures in c and how to use them?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What is the purpose of & in scanf?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
Where define directive used?
What are run-time errors?
Do pointers store the address of value or the actual value of a variable?
How can I avoid the abort, retry, fail messages?
What is volatile, register definition in C