Write C# Program to Find the Largest Number using Conditional Operator

Write C# Program to Find the Largest Number using Conditional Operator


Introduction

Write C# Program to Find the Largest Number using Conditional Operator. 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, largest;
  10.  
  11. Console.WriteLine("Enter three numbers:");
  12. num1 = Convert.ToInt32(Console.ReadLine());
  13. num2 = Convert.ToInt32(Console.ReadLine());
  14. num3 = Convert.ToInt32(Console.ReadLine());
  15.  
  16. largest = num1 > num2 ? (num1 > num3 ? num1 : num3) : (num2 > num3 ? num2 : num3);
  17.  
  18. Console.WriteLine(largest + " is the largest number.");
  19.  
  20. Console.ReadLine();
  21.  
  22. }
  23. }
  24. }
  25.  

Result

C# language techstudy.org

     





Related Topics




Popular Posts