Created
May 21, 2017 13:04
-
-
Save miteshsureja/fe0e8923c9a4fc5f774be20ed70ba7a8 to your computer and use it in GitHub Desktop.
Find Max and Min value from List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace RandomNumbers | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<int> myList = new List<int>() { 12, 4, 32, 8, 9, 20 , 5, 56, 76, 98}; | |
int max = myList[0], min = myList[0]; | |
for (int i = 0; i < myList.Count; i++) | |
{ | |
if (myList[i] > max) | |
max = myList[i]; | |
if (myList[i] < min) | |
min = myList[i]; | |
} | |
Console.WriteLine("Max - {0}", max); | |
Console.WriteLine("Min - {0}", min); | |
Console.Read(); | |
} | |
} | |
} |
Author
miteshsureja
commented
May 21, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment