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 is Lazy evaluation in C? Give an example.

1 Answers  


Can we include one C program into another C program if yes how?

7 Answers   Infosys,


Where are some collections of useful code fragments and examples?

0 Answers   Celstream,


What is a good way to implement complex numbers in c?

0 Answers  


difference between semaphores and mutex?

1 Answers  






#ifdef TRUE int I=0; #endif main() { int j=0; printf("%d %d\n",i,j); }

3 Answers   ADITI,


how to find turn around time in operating system?

3 Answers  


hi any body pls give me company name interview conduct "c" language only

0 Answers  


i have a written test in tomorrow

1 Answers   NNN, Value Labs,


Why is c still so popular?

0 Answers  


what is the hexidecimal number of 4100?

16 Answers   Google,


Tell us the use of fflush() function in c language?

0 Answers  


Categories