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

how can we print  hellow world programme without using semicolon

3 Answers  


what is the basis for selection of arrays or pointers as data structure in a program

0 Answers   TCS,


What are the 4 types of functions?

0 Answers  


program to get the remainder and quotant of given two numbers with out using % and / operators?

10 Answers   College School Exams Tests, IBM,


What is the explanation for modular programming?

0 Answers  






write a c program in such a way that if we enter the today date the output should be next day's date.

0 Answers  


What is the use of function overloading in C?

0 Answers   Ittiam Systems,


Write a program in c to print * * * * * *******

1 Answers  


Explain following declaration int *P(void); and int (*p)(char *a);

3 Answers  


what is pointer ?

10 Answers   Kernex Micro Systems,


IS it possible to define a zero sized array in c.if it is possible how can the elements of that array can be accessed.array index starts from zero,if it is possible to define zero sized array how can be its first element can be accesseed.

5 Answers   TCS,


write C code to reverse a string such that if i/p is "abc defg hij klmno pqrs tuv wxyz" and the o/p should be "cba gfed jih onmlk srqp vut zyxw"

2 Answers  


Categories