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 is a lvalue
Why is c faster?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
Explain what are binary trees?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
What is the basic structure of c?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What are the 5 data types?
What is the scope of an external variable in c?
What is array in c with example?
Tell me about low level programming languages.
What is a constant?
Which function in C can be used to append a string to another string?
How does pointer work in c?
Is it better to use malloc() or calloc()?