Q:

Write C# program to find maximum number using switch case

0

Write C# program to find maximum number using switch case

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

using System;
 
class Program
{
 
    static void Main(string[] args)
    {
 
        int num1=0, num2=0;
 
        //Reading two numbers from user
        Console.WriteLine("Enter two numbers to find maximum number: ");
        num1 = Convert.ToInt32(Console.ReadLine());
        num2 = Convert.ToInt32(Console.ReadLine());        
 
        // Condition to check maximum number
 
        switch (num1 > num2)
        {
            case true: Console.WriteLine(num1 + " is Maximum number");            
            break;
 
            case false: Console.WriteLine(num2+" is Maximum number");
            break;
 
        }
 
        Console.ReadLine();
 
    }
 
}

Result:

Enter two numbers to find maximum number: 

50

20

50 is Maximum number

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

<< Write C# program to print gender (Male/Female) pro...