Second maximum number

How to find out second maximum number in C#?

Questions by tmounika   answers by tmounika

Showing Answers 1 - 5 of 5 Answers

Werty

  • Nov 10th, 2013
 

For example.

Code
  1. span style="color: #ff0000;">"max2="+max2);

Deepak

  • Mar 11th, 2015
 

Use LINQ

  Was this answer useful?  Yes

This code will work even if array will have a few maximums. Ex: (10, 8, 8, -2, 4, 10, 1)

Code
  1. span style="color: #ff0000;">"array has to have at least 2 elements"// array has all the same elements. In this case we

  Was this answer useful?  Yes

Roger Hyde

  • Feb 6th, 2016
 

Linq makes this quite simple

Code
  1.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions