Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a macro in c preprocessor?

1108


Explain how do you determine a file’s attributes?

1051


What is the difference between c and python?

1184


Explain what is wrong with this program statement?

1126


Write a code to generate divisors of an integer?

1078


Why do we use namespace feature?

1065


what is the function of pragma directive in c?

1127


`write a program to display the recomended action depends on a color of trafic light using nested if statments

2139


What do you mean by recursion in c?

1119


In c language can we compile a program without main() function?

1145


Is there a way to jump out of a function or functions?

1111


which type of aspect you want from the student.

2168


What are header files and explain what are its uses in c programming?

1135


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1380


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.

2001