find second largest element in array w/o using sorting
techniques? use onle one for loop.
Answer Posted / athul
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],n,i,big,big2;
cout<<"Enter the limit\n";
cin>>n;
cout<<"Enter the arrays\n";
for(i=0;i<n;i++)
{
cin>>a[i];
big=a[0];
}
for(i=0;i<n;i++)
{
if(big<a[i])
{
big2=big;
big=a[i];
}
else if(big2<a[i])
{
big2=a[i];
}
}
cout<<"The second biggest number is "<<big2<<endl;
getch();
}
| Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
What is a macro in c preprocessor?
Explain how do you determine a file’s attributes?
What is the difference between c and python?
Explain what is wrong with this program statement?
Write a code to generate divisors of an integer?
Why do we use namespace feature?
what is the function of pragma directive in c?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
What do you mean by recursion in c?
In c language can we compile a program without main() function?
Is there a way to jump out of a function or functions?
which type of aspect you want from the student.
What are header files and explain what are its uses in c programming?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.