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
Explain what’s a signal? Explain what do I use signals for?
How is a pointer variable declared?
Define VARIABLE?
What is the best way to store flag values in a program?
How do I use void main?
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 .
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Explain the ternary tree?
What is the difference between a free-standing and a hosted environment?
What is scope rule of function in c?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
Is void a keyword in c?
Explain how do you search data in a data file using random access method?
Differentiate between full, complete & perfect binary trees.
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.