Write C# program to find maximum number using switch case


Introduction

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

techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1. using System;
  2.  
  3. class Program
  4. {
  5.  
  6. static void Main(string[] args)
  7. {
  8.  
  9. int num1=0, num2=0;
  10.  
  11. //Reading two numbers from user
  12. Console.WriteLine("Enter two numbers to find maximum number: ");
  13. num1 = Convert.ToInt32(Console.ReadLine());
  14. num2 = Convert.ToInt32(Console.ReadLine());
  15.  
  16. // Condition to check maximum number
  17.  
  18. switch (num1 > num2)
  19. {
  20. case true: Console.WriteLine(num1 + " is Maximum number");
  21. break;
  22.  
  23. case false: Console.WriteLine(num2+" is Maximum number");
  24. break;
  25.  
  26. }
  27.  
  28. Console.ReadLine();
  29.  
  30. }
  31.  
  32. }

Result

C# language techstudy

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.