When debugging why does visual studio say median is an unassigned variable? -Answered
<p>So, I am trying to make a console program that analyzes data(well kind of). The problem is when I go to print the median it tells me it is unassigned(well the debugger says this actually). What did I do wrong?
using System;</p>

<pre><code>using System;

class midpointFormula
{
    static void Main()
    {
    double min, max, range, median, quartile1, quartile3, internalQuartileRange, IQR15;
    int dataPoints, dataPoints1, count, count1;
    double[] dataSet;
    bool isEven;

    count = 0;

    Console.WriteLine("This program allows you to find several diffrent values from the data");
    Console.Write("Please enter the amount of data points you would like to use: ");

    dataPoints = int.Parse(Console.ReadLine());
    dataPoints1 = dataPoints - 1;

    dataSet = new double[dataPoints];

    #region Enter Data
    while (count &lt; dataPoints)
    {

        count1 = count + 1;

        Console.Write("Please enter the {0} datapoint: ", count1);

        dataSet[count] = double.Parse(Console.ReadLine());

        ++count;

    }
    #endregion

    min = dataSet[0];
    max = dataSet[dataSet.Length - 1];
    range = max - min;


    #region Even Check
    if (dataPoints % 2 == 0)
    {
    isEven = true;
    }
    else
    {
    isEven = false;
    }
    #endregion

    if (isEven == true)
    {
        int medianPoint;

        medianPoint = (dataPoints / 2) - 1;

        median = dataSet[medianPoint];


    }
    else


    #region Output
    Console.WriteLine("Minimum is : {0}", min);
    Console.WriteLine("Maximum is : {0}", max);
    Console.WriteLine("Range is   : {0}", range);
    Console.WriteLine("Median is  : {0}", median);
    #endregion

    Console.ReadKey();
}
</code></pre>

<p>}</p>

<p>Note: Yes, I know if there is an uneven amount of datapoints it will not calculate the data points, I am still working on that.</p>
