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 ");
}
}
}
0 comments:
Post a Comment