Write a program that will ask the user to enter 100 numbers and display on the screen the highest and lowest of these numbers.
1
Expert's answer
2012-08-30T09:43:16-0400
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication1 { class Program { & static void Main(string[] args) & {
int[] array = new int[100];
for (int i = 0; i < 100; i++) { array[i] = int.Parse(Console.ReadLine()); } int max = array[0], min = array[0]; for (int i = 1; i < 100; i++) { if (array[i] > max) max = array[i]; if (array[i] < min) min = array[i]; } Console.WriteLine("Max: " + max + "\nMin: " + min); & } } }
Comments
Leave a comment