jrliv
5/19/2017 - 12:30 PM

Example of an if statement used to find the largest number.

Example of an if statement used to find the largest number.

Console.Write("Enter the first number: ");
int first = int.Parse(Console.ReadLine());

Console.Write("Enter the second number: ");
int second = int.Parse(Console.ReadLine());

int largest = first;

if (second > first)
{
	largest = second;
}
Console.WriteLine("The bigger number is: {0}", largest);

// Enter the first number:
// 5
// Enter the second number: 
// 10
// The bigger number is: 10