find second largest element in array w/o using sorting
techniques? use onle one for loop.
Answer Posted / k.shravan
main()
{
int a[10],min,max,temp,i;
clrscr();
printf("\n\n Enter the array=>");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
min=max=a[0];
for(i=1;i<5;i++)
{
if(a[i]>max)
{
min=max;
max=a[i];
}
if(a[i]<max && a[i]>min)
{
min=a[i];
}
}
printf("%d---%d",max,min);
getch();
}
| Is This Answer Correct ? | 7 Yes | 11 No |
Post New Answer View All Answers
What are the advantage of c language?
What is string function in c?
Which header file should you include if you are to develop a function which can accept variable number of arguments?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
What happens if a header file is included twice?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
How are variables declared in c?
What is the explanation for modular programming?
How is actual parameter different from the formal parameter?
Why isnt any of this standardized in c?
Why functions are used in c?
Explain bit masking in c?
What is c standard library?
All technical questions