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


Please Help Members By Posting Answers For Below Questions

Explain what’s a signal? Explain what do I use signals for?

616


How is a pointer variable declared?

596


Define VARIABLE?

692


What is the best way to store flag values in a program?

583


How do I use void main?

635






hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1906


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

678


Explain the ternary tree?

605


What is the difference between a free-standing and a hosted environment?

644


What is scope rule of function in c?

555


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

762


Is void a keyword in c?

582


Explain how do you search data in a data file using random access method?

700


Differentiate between full, complete & perfect binary trees.

675


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

1524