Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Demo
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list = new List<int> { 3, 4, 5, 6 };
- Console.WriteLine(Sum(list));
- Console.WriteLine(Average(list));
- }
- public static int Sum( List<int> list)
- {
- int sum = 0;
- foreach(int number in list)
- {
- sum += number;
- }
- return sum;
- }
- public static double Average(List<int> list)
- {
- return Sum(list) * 1.0 / list.Count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment