write a program to find the largest and second largest
integer from an array

Answers were Sorted based on User's Feedback



write a program to find the largest and second largest integer from an array..

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

write a program to find the largest and second largest integer from an array..

Answer / mahesh

use bubble sort next to this, print last n second from last..

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

What do you mean by invalid pointer arithmetic?

0 Answers  


how to find sum of 5 digits in C?

4 Answers  


What is #error and use of it?

0 Answers  


Describe explain how arrays can be passed to a user defined function

0 Answers  


Explain how can you tell whether a program was compiled using c versus c++?

0 Answers  






What is the benefit of using const for declaring constants?

0 Answers  


what is the advantage of software development

1 Answers  


how to find the binary of a number?

10 Answers   Infosys,


write a program to rearrange the array such way that all even elements should come first and next come odd

0 Answers  


Explain what is the difference between declaring a variable and defining a variable?

1 Answers  


What are bitwise shift operators in c programming?

0 Answers  


How would you write qsort?

1 Answers  


Categories