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 is structure data type in c?
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
What is huge pointer in c?
What are different storage class specifiers in c?
difference between native and cross compilers
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
What is a pragma?
Difference between malloc() and calloc() function?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
What is an lvalue in c?
What is sizeof c?
What is spark map function?
Should I learn data structures in c or python?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
what is the role you expect in software industry?