write a program to find the largest and second largest
integer from an array
Answers were Sorted based on User's Feedback
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 |
Answer / mahesh
use bubble sort next to this, print last n second from last..
| Is This Answer Correct ? | 1 Yes | 1 No |
What is meant by type specifiers?
What are the modifiers available in c programming language?
what information does the header files contain?
6 Answers BSNL, Cisco, GDA Technologies,
Where static variables are stored in memory in c?
List out few of the applications that make use of Multilinked Structures?
compare array with pointer?
Prove or disprove P!=NP.
what is the difference between const char *p, char const *p, const char* const p
5 Answers Accenture, Aricent, CTS, Geometric Software, Point Cross, Verizon,
How can I list all of the predefined identifiers?
what is difference between array of characters and string
What is indirect recursion? give an example?
Reverse the bit order in a single macro. eg. i/p = 10010101 --> o/p = 10101001