Advertisement
stamen4o

Min, Max, Sum and Average of N Numbers

Mar 26th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class MinMaxSum
  4. {
  5. static void Main()
  6. {
  7. Console.Title = "Min, Max, Sum and Average of N Numbers";
  8. Console.Write("Enter how many n: ");
  9. int n = int.Parse(Console.ReadLine());
  10. float[] arrNum = new float[n];
  11. for (int i = 1; i <= n; i++)
  12. {
  13. Console.Write("Enter n {0}: ",i);
  14. arrNum[i - 1] = float.Parse(Console.ReadLine());
  15. }
  16. float min = arrNum.Min();
  17. float max = arrNum.Max();
  18. float sum = arrNum.Sum();
  19. float avg = arrNum.Average();
  20. Console.WriteLine("min is {0:0.00} \nmax is {1:0.00} \nsum is {2:0.00} \navg is {3:0.00}", min, max, sum, avg);
  21. Main();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement