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 the scope of global variable in c?
Difference between MAC vs. IP Addressing
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
What is indirection in c?
What is the advantage of an array over individual variables?
Explain what is a pragma?
If the size of int data type is two bytes, what is the range of signed int data type?
explain what is a newline escape sequence?
Why we write conio h in c?
What are header files why are they important?
What are the types of unary operators?
Explain data types & how many data types supported by c?
What is meant by recursion?
Place the #include statement must be written in the program?