Question: Hello I have tried to follow learning on codeasy.net, I have reached chapter 4 where it asks this: 

Write a program that reads from the console three numbers each from the new line and then outputs the middle by the value of these three numbers. 

```
Example:
 >54
 >4456
 >2
 54

```

I have tried all the code I know as a beginner and it is still wrong. My current code is this:

```
using System;

namespace ConsoleInput
{
public class TheMiddle
{
    public static void Main(string[] args)
    {
          int a = int.Parse(Console.ReadLine());
          int b = int.Parse(Console.ReadLine());
          int c = int.Parse(Console.ReadLine()); 

       if (a < b && c < b)
       Console.WriteLine(a);
       if (a < b && b < c)
       Console.WriteLine(b);
       if (c < b && a < c)
       Console.WriteLine(c);
       if (a < b && c > b )
       Console.WriteLine(a);
       else
       if (a > b && c > a)
       Console.WriteLine(a);
       if (a > b && b > c)
       Console.WriteLine(b);
      if (c > b && b > a)
      Console.WriteLine(a);
       if (b > a && c > a)
       Console.WriteLine(c);

    }
 }
}

```

Answer: 
You need to make more comparisons. There are 3 cases.

```
if((a <= b && b <= c) || (c <= b && b <= a))
    Console.WriteLine(b);
if((b <= a && a <= c) || (c <= a && a <= b))
    Console.WriteLine(a);
if((a <= c && c <= b) || (b <= c && c <= a))
    Console.WriteLine(c);

```

Basically the number is in the middle of the other two and you have to check the case where the the other two numbers are on either side. So for example `b` is in the middle if it's between `a` and `c` in that order, or between `c` and `a` in that order.
```
using System;

namespace ConsoleInput
{
public class TheMiddle
{
    public static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());

        int result;
        if (a < b)
        {
            if (c < a)
                result = a;
            else if (c > b)
                result = b;
            else
                result = c;
        }
        else
        {
            if (c < b)
                result = b;
            else if (c > a)
                result = a;
            else
                result = c;
        }

        Console.WriteLine(result);
    }
  }
}

```

this is the answer.