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 spaghetti programming?
What is the use of #define preprocessor in c?
When c language was developed?
What is the explanation for the dangling pointer in c?
What is the use of printf() and scanf() functions?
how can I convert a string to a number?
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
Why c is procedure oriented?
How can I split up a string into whitespace-separated fields?
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
write a program to copy the string using switch case?
FILE PROGRAMMING
What is the best way to store flag values in a program?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
What do you understand by normalization of pointers?