FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 90   



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

using System;

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

Output:

Example1:

Enter three numbers:
 5
 5
 5
All numbers are equal

Example2:

Enter three numbers:
 2
 4
 6
6 is  larger than 4 and 2



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News