Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Min, Max, Sum and Average #5

Open
nrgbatman opened this issue Apr 30, 2019 · 0 comments
Open

Min, Max, Sum and Average #5

nrgbatman opened this issue Apr 30, 2019 · 0 comments

Comments

@nrgbatman
Copy link
Owner

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Min__Max__Sum_and_Average
{
class Program
{
static void Main(string[] args)
{

        int n = int.Parse(Console.ReadLine());
        double a = 0;

        double min = double.MaxValue;
        double max = double.MinValue;
        double sum = 0;
        double avg = 0;


        for (int i = 0; i < n; i++)
        {
            a = double.Parse(Console.ReadLine());
            if (a < min)
            {
                min = a;
            }
            if (a > max)
            {
                max = a;
            }
            sum += a;

        }
        avg = sum / n;

        Console.WriteLine("min={0:f2}",min);
        Console.WriteLine("max={0:f2}",max);
        Console.WriteLine("sum={0:f2}",sum);
        Console.WriteLine("avg={0:f2}",avg);



    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant