Skip to content

Instantly share code, notes, and snippets.

@IvanNikolov
Created October 15, 2014 11:53
Show Gist options
  • Save IvanNikolov/c2d689d80e2d5208613a to your computer and use it in GitHub Desktop.
Save IvanNikolov/c2d689d80e2d5208613a to your computer and use it in GitHub Desktop.
using System;
//Write a program that finds the biggest of five numbers
//by using only five if statements.
class BiggestOf5Numbers
{
static void Main()
{
double a = double.Parse(Console.ReadLine());
double b = double.Parse(Console.ReadLine());
double c = double.Parse(Console.ReadLine());
double d = double.Parse(Console.ReadLine());
double e = double.Parse(Console.ReadLine());
if ((a>b && a>c) && (a>d && a>e)) //checks a
{
Console.WriteLine(a);
}
if ((b>a && b>c) && (b>d && b>e)) //checks b
{
Console.WriteLine(b);
}
if ((c>a && c>b) && (c>d && c>e)) //checks c
{
Console.WriteLine(c);
}
if ((d>a && d>b) && (d>c && d>=e)) //checks c
{
Console.WriteLine(d);
}
if ((e>a && e>b) && (e>c && e>d)) //checks e
{
Console.WriteLine(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment