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

In a survey of town of Wasco, it was found that 65% of the people surveyed watched the news on television, 40% read newspaper, and 25% read a newspaper and watched the news on television. What percent of the people surveyed neither watched the news on the television nor read a newspaper?.

0 Answers   Wipro,


What is the calibration procedure for UV Spectrophotometer

2 Answers  


pick out the number which is different from other four. a) 49 b)25 c)36 d)81 e)64 plz specify the reason.... thanks

24 Answers   Central Bank of India, Podium Solutions,


out of 55 eggs 5 are defective. what is % of defective eggs

13 Answers   Wipro,


MMID full form?

1 Answers   Bank Exams,






15 men take 21 days of 8 hrs. each to do a piece of work. How many days of 6 hrs. each would it take for 21 women if 3 women do as much work as 2 men?

0 Answers   Mu Sigma,


A TV set, with a marked price of Rs.14,000 was sold for Rs.11,214 after two successive discounts. If the first discount was 11%, what was the second discount?

7 Answers  


In a certain code language TRANSPORT is written as RTASNPORT. How will the word GATEHOUSE be written in that code language ? (a) ETGAHOESU (b) ETAGHESUO (c) AGTHEOUSE (d) AGETHUOES (e) None of these

5 Answers  


If asked you, why you want to regin the current company/organisition

0 Answers  


Ram was travailing back from his friend house in his old ambassador. He could only travel along at a steady 30 miles per hr and managed a paltry 20 miles per litere of fuel. At the start of the journey he has placed exactly 10 litre of fuel into a tank. He knew though that the fuel tank lost fuel at the rate of half a liter per hhour. As ram arrived home the car stopped because it had run out of a fuel and h only just made it. How far was his friends house from rams. a.200 b.150 3.210 d170

2 Answers   Caritor,


If A:B =5:9, B:C=3:8 then A:B:C=?

22 Answers   College School Exams Tests, HCL, Zoho,


there are 27 coins in which 0ne is heavier than rest(all equal weight).how many measurements are needed to isolate that odd one.

2 Answers   Verifone,


Categories