Advertisement
KlimentHristov

Array.MinMaxAverageSum

Dec 1st, 2015
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class MinMaxAverageSumOfNumbers
  4. {
  5.     // CONDITION:
  6.     // Write a program that reads from the console a sequence of n integer numbers and returns the minimal, the maximal number, the sum and the average of all numbers (displayed with 2 digits after the decimal point). The input starts by the number n (alone in a line) followed by n lines, each holding an integer number.
  7.     static void Main()
  8.     {
  9.         Console.Write("Enter N numbers:");
  10.         int n = int.Parse(Console.ReadLine());
  11.         double[] numArr = new double[n];
  12.         double[] secondArr = numArr;
  13.         for (int i = 0; i < n; i++)
  14.         {
  15.             Console.Write("{0}.integer: ",i);
  16.             numArr[i] = double.Parse(Console.ReadLine());
  17.         }
  18.         Console.WriteLine(numArr.Min());
  19.         Console.WriteLine(numArr.Max());
  20.         Console.WriteLine(secondArr.Sum());
  21.         Console.WriteLine("{0:F2}",numArr.Average());
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement