Hello!

I want to write code that calculates the arithmetic average of a series of numbers. Please tell me how to do it. Take an array? Or something different? I need the user to enter how many numbers he wants.

    1 answer 1

    http://ideone.com/fSEFJm

    Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Average()); 

    The user must enter at least one number, otherwise it will fall.

    • And not to fall? - Piston
    • @Piston, check the length of the read string. And it will still fall if the input format is incorrect. - Qwertiy
    • What code do I need to write to not fall? And please tell me how to check the length of the string? And what is it for? - Piston
    • @Piston, and do something yourself? - Qwertiy
    • one
      @Piston, but "started studying" is "started asking to do everything for me"? What exactly is the problem? - Qwertiy