I need to write a program that finds the biggest of five numbers by using only five if statements.

Examples:

 a b c d e biggest 5 2 2 4 1 5 -2 -22 1 0 0 1 -2 4 3 2 0 4 0 -2.5 0 5 5 5 -3 -0.5 -1.1 -2 -0.1 -0.1

retagged

+1 vote

Try this code:

```using System;

class TheBiggestOfFiveNumbers
{
static void Main()
{

if ((a >= b) && (a >= c) && (a >= d) && (a >= e))
{
Console.WriteLine("The biggest number is: {0}", a);
return;
}
if ((b >= a) && (b >= c) && (b >= d) && (b >= c))
{
Console.WriteLine("The biggest number is: {0}", b);
return;
}
if ((c >= a) && (c >= b) && (c >= d) && (c >= e))
{
Console.WriteLine("The biggest number is: {0}", c);
return;
}
if ((d >= a) && (d >= b) && (d >= c) && (d >= e))
{
Console.WriteLine("The biggest number is: {0}", d);
return;
}
if ((e >= a) && (e >= b) && (e >= c) && (e >= d))
{
Console.WriteLine("The biggest number is: {0}", e);
return;
}
}
}
```
edited by user golearnweb

Or you can do it with an array and use on it the method .Max();

Like this:

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

{
static void Main()
{