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 does not c have an exponentiation operator?
Implement bit Array in C.
Why should I use standard library functions instead of writing my own?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
Write a C program in Fibonacci series.
How can you access memory located at a certain address?
What are the back slash character constants or escape sequence charactersavailable in c?
Why does everyone say not to use gets?
In C programming, what command or code can be used to determine if a number of odd or even?
Is that possible to store 32768 in an int data type variable?
What does the function toupper() do?
How do you convert strings to numbers in C?
What is the difference between c and python?
How can I ensure that integer arithmetic doesnt overflow?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9