ques-Input an array and prints the second minimum in an array??
Example
Input:34,45,21,12,54,67,15
Output:15
I want a solution in C/C++ language

Answers were Sorted based on User's Feedback



ques-Input an array and prints the second minimum in an array?? Example Input:34,45,21,12,54,67,15..

Answer / amit rawat

#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int ar[6]={21,23,14,65,2,35};
for(int i=0;i<6;i++)
{for(int j=0;j<i;j++)
{if(ar[i]<ar[j])
{int min=ar[i];
ar[i]=ar[j];
ar[j]=min;
}
}
}
cout<<"\n";
cout<<ar[1]<<"is the second lowest no";
getch();

Is This Answer Correct ?    4 Yes 2 No

ques-Input an array and prints the second minimum in an array?? Example Input:34,45,21,12,54,67,15..

Answer / om prakash

#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int ar[6]={21,23,14,65,2,35};
int min1=ar[0],min2=ar[0];
for(int i=1;i<6;i++)
{
if(min1<ar[i])
{
int min2=min1;
min1=ar[i];
}
}
print(min2);
getch();

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More General Aptitude Interview Questions

The Youngest prime minister of India _____________

5 Answers  


A storm will move with a velocity of towords the center in hours. At the same rate how much far will it move in hrs.

0 Answers   Accenture,


Which of the following is not a valid DEFINE GDG parameter a) OWNER b)LIMIT c) SCRATCH c)ALTER

0 Answers   HDFC,


what would be the next number in the sequence 1,2,10,4,3,14,9,5, ?

3 Answers  


a number of subsets of a set s is 128, then s has

0 Answers   DSQ Software,






be * be = acb a,b,c,e are non zero numbers find b,e.

0 Answers   Infosys,


I ASKED A WOMAN WHAT WAS HER AGE?. SHE REPLIED THAT HER HUSBAND'S AGE IS REVERSE OF HER. AND THE DIFFERENCE BETWEEN THEIR AGES IS ONE ELEVENTH OF THEIR SUM. FIND OUT WHAT WAS HER AGE AND HER HUSBAND'S AGE?.

3 Answers  


mukesh and anil ambani invested amount in business and made in the ration 17:13 and made some profits. if mukesh earned 800 rs more than anil. then what is the profit they have earned....?

2 Answers  


I am applying for vizag steel plant management recruitment for 2009 please can anybody send me the pattern of the written test paper

31 Answers   Salem Steel Plant, Steel Plant, TATA, Vizag Steel, VSP,


A grosser purchased 80kg of rice at Rs.13.50 per kg and mixed it with 120kg rice at Rs 16 per kg.At what rate per kg should he sell the mixture to gain 16% ?

4 Answers  


If 6 years are subtracted from the present age of the remainder is divided by 18, then the present age of his grandson Anup is obtained. If Anup is 2 years younger to Madan whose age is 5 years,then what is Gagan's present age?

3 Answers  


In certain code 'OPERATION' is written as 'POREAITNO'How is DREAMLAND written in that code.

4 Answers   Infosys,


Categories