C# program to find largest number from given 2 numbers


Following program shows you how to find largest number from given 2 numbers.
In this program we get inputs from user and shows largest number from given two numbers using if condition

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Enter two numbers:");
    int input1 = Convert.ToInt32 (Console.ReadLine());
    int input2 = Convert.ToInt32(Console.ReadLine());
    if (input1 == input2) {
      Console.WriteLine (input1 + " is equal to " + input2);
    }else if (input1 > input2) {
      Console.WriteLine (input1 + " is larger than " + input2);
    }else {
      Console.WriteLine (input1 + " is lesser than " + input2);
    }
  }
}

Output:

Example1:

Enter two numbers:
 11
 11
11 is equal to 11

Example2:

Enter two numbers:
 22
 17
22 is larger than 17

Example3:

Enter two numbers:
 5
 12
5 is lesser than 12