Enter a double value 11.11
Enter a double value 22.22
Enter a double value 33.33
Enter a double value 44.44
Enter a double value 55.55
The total is 166.65
Press any key to continue
1
Expert's answer
2016-05-04T09:40:02-0400
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Schema;
namespace rand { class Program { static void Main(string[] args) { Random rand = new Random(); double[] mas = new double[20]; double sum = 0; for (int i = 0; i < 20; i++) { mas[i] = rand.Next(0, 1000); sum += mas[i]; Console.WriteLine((i+1) + " number is "+mas[i].ToString()); } Console.WriteLine(); Console.WriteLine("The Total is: " + sum.ToString()); Console.WriteLine("The average of the 20 random numbers is: " + (sum / 20.0).ToString()); Console.ReadLine(); } } }
Comments
Leave a comment