Get greater number in runtime..

NIITSANJEEV
Posted by NIITSANJEEV under C# category on | Points: 40 | Views : 1069
using System;
class perfect
{
public static void Main()
{
Console.WriteLine("Enter First number");
int num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second number");
int num2 = Convert.ToInt32(Console.ReadLine());
{
if (num1 > num2)
{
Console.WriteLine("A is greater");
}
else
{
Console.WriteLine("B is greater");

}
}
}
}

Comments or Responses

Posted by: T.Saravanan on: 2/21/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Kindly post your code inside the code tag.

I have one question from your code.If I am using same "value" in both num1 and num2 means which is return from your code.
For example --> num1 = 10; num2 = 10;

Just for fun. Kindly check and change it.
Posted by: Omniitstudent on: 2/21/2012 Level:Starter | Status: [Member] | Points: 10
using System;
class perfect
{
public static void Main()
{
Console.WriteLine("Enter First number");
int num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Second number");
int num2 = Convert.ToInt32(Console.ReadLine());

if (num1>num2)
{
Console.WriteLine("num1 is greater ");

}
else if (num2>num1)
{
Console.WriteLine("num2 is greater ");
}
else
{
Console.WriteLine("both are equals ");

}


Console.ReadLine();

}
}
crazy code..

Login to post response