find second largest element in array w/o using sorting
techniques? use onle one for loop.

Answer Posted / anamika datta

#include<stdio.h>
#include<conio.h>
void main()
{
int n[]={5,3,4};
int i,large,sec_large;
clrscr();

large=sec_large=n[0];
for(i=0;i<3;i++)
{
if(n[i]>large)
{
sec_large=large;
large=n[i];
}

}
printf("%d",sec_large);
}
getch();

Is This Answer Correct ?    10 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational

815


What is the process to create increment and decrement stamen in c?

590


Why C language is a procedural language?

625


What should malloc() do?

649


Write a program with dynamically allocation of variable.

607






Differentiate between #include<...> and #include '...'

619


What are different types of operators?

600


Explain what is wrong with this program statement?

624


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

722


How many levels deep can include files be nested?

654


What does nil mean in c?

676


Why clrscr is used after variable declaration?

1043


Give basis knowledge of web designing ...

1578


Explain how can a program be made to print the name of a source file where an error occurs?

693


explain what is an endless loop?

614