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
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
How many types of operators are there in c?
How to create struct variables?
What should malloc(0) do?
What is a spanning Tree?
What is pointer and structure in c?
what is the syallabus of computer science students in group- 1?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Explain how do you search data in a data file using random access method?
What is huge pointer in c?
What is the 'named constructor idiom'?
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
In C, What is the #line used for?
What the different types of arrays in c?
Are there namespaces in c?