Write C# Program to find the Largest among Three Variables using Nested if


Introduction

Write C# Program to find the Largest among Three Variables using Nested if. 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. namespace csharpprograms
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int num1, num2, num3;
  10. Console.WriteLine("Enter three numbers: \n");
  11.  
  12. num1 = Convert.ToInt32(Console.ReadLine());
  13. num2 = Convert.ToInt32(Console.ReadLine());
  14. num3 = Convert.ToInt32(Console.ReadLine());
  15.  
  16. if (num1 >= num2)
  17. {
  18. if (num1 >= num3)
  19. Console.WriteLine(num1+" is the largest number");
  20. else
  21. Console.WriteLine(num3 + " is the largest number");
  22. }
  23.  
  24. else if (num2 >= num3)
  25. Console.WriteLine(num2 + " is the largest number");
  26.  
  27. else
  28. Console.WriteLine(num3 + " is the largest number");
  29.  
  30. Console.ReadLine();
  31.  
  32.  
  33. }
  34. }
  35. }
  36.  

Result

C# language techstudy.org

     





Related Topics




Popular Posts