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 structural principle?
What is omp_num_threads?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
What math functions are available for integers? For floating point?
What is the Purpose of 'extern' keyword in a function declaration?
What are the types of pointers?
What are the different types of data structures in c?
What does volatile do?
Explain what is the use of a semicolon (;) at the end of every program statement?
What is the symbol indicated the c-preprocessor?
What is the significance of an algorithm to C programming?
i have a written test for microland please give me test pattern
Why we write conio h in c?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer