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

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  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




Popular Posts