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

In this simple C# tutorial check between two 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 two variables "num1" for number one and "num2" for number two. To check greater number we are taking "if-else" condition statement.

using System;
​class check
{
 public static void Main(String []args)
 {
        float num1,num2;
        Console.WriteLine("Enter number one:");
        num1=Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Enter number two:");
        num2=Convert.ToInt32(Console.ReadLine());
        if(num1>num2)
        {
          Console.WriteLine("\nnumber one is greater ");  
        }
        else 
        {
          Console.WriteLine("\nnumber two is greater ");     
        }
         
 }
}
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