The code needs to be in C #.
Write a simple program that reads from the console a set of numbers and prints back onto the console the smallest number from the collection
using System; class Program { static void Main() { int min; string s; Console.WriteLine("Enter space separated numbers: "); s = Console.ReadLine(); string[] splits = s.Split(' '); int[] numbers = new int[splits.Length]; for (int i = 0; i<numbers.Length; i++) { string tmp=splits[i].Trim(); numbers[i] = int.Parse(tmp); } min = numbers[0]; for(int i = 1;i<numbers.Length;i++){ if(min > numbers[i]){ min = numbers[i]; } } Console.WriteLine("Smallest number = "+min); } }
Get Answers For Free
Most questions answered within 1 hours.