In this simple C# tutorial check between three numbers which is the greater one. Here we take "float" datatype, you can also take "int" or "double" datatype too depending on the number entered by the user. Here we are taking three variables "num1" for number one and "num2" for number two and "num3" for number three. To check greater number we are taking "if-else" condition statement. Now, lets get started!!
using System; class check { public static void Main(String []args) { float num1,num2,num3; Console.WriteLine("Enter number one:"); num1=Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter number two:"); num2=Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter number three:"); num3=Convert.ToInt32(Console.ReadLine()); if(num1>num2) { if(num1>num3) { Console.WriteLine("\nnumber one is the biggest no "); } else if(num2>num3) { Console.WriteLine("\nnumber two is the biggest no "); } } else { Console.WriteLine("\nnumber three is the biggest no "); } } }
0 comments:
Post a Comment