C# : Program to check between three numbers which is the greater one

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 ");
        }    
 }
}
SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment