hi i want to sort this array using c# to find maximum and minimum values from the 10 numbers entered.
Code:int[] marks = new int [9]; int max=0; int min=0; int x; int y; Console.WriteLine("enter the marks of ten students and i will tell u which is maximum and minimum"); for (x = 0; x < marks.Length; x++) { marks[x] = Convert.ToInt32(Console.ReadLine()); //min = marks[0]; } for (y = 0; y < marks.Length; y++) { //here if starting no is greater than ending no than it will display the lowest and highest no if (min<marks[0]) { min = marks[0]; Console.WriteLine("{0} is the minimum", min); Console.ReadLine(); } else if (min>marks[1]) { max = marks[1]; Console.WriteLine("{0} is the maximum", max); Console.ReadLine(); } //} // Console.WriteLine("the highest is {0} and the lowest is {1}", marks,min); }




Reply With Quote