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 do you mean by invalid pointer arithmetic?
how to find sum of 5 digits in C?
What is #error and use of it?
Describe explain how arrays can be passed to a user defined function
Explain how can you tell whether a program was compiled using c versus c++?
What is the benefit of using const for declaring constants?
what is the advantage of software development
how to find the binary of a number?
write a program to rearrange the array such way that all even elements should come first and next come odd
Explain what is the difference between declaring a variable and defining a variable?
What are bitwise shift operators in c programming?
How would you write qsort?