Comparing integers using if statements, equality operators, and relational operators.
using System;
public class Comparison
{
public static void Main( string[] args )
{
int number1;
int number2;
Console.Write( "Enter first integer: " );
number1 = Convert.ToInt32( Console.ReadLine() );
Console.Write( "Enter second integer: " );
number2 = Convert.ToInt32( Console.ReadLine() );
if ( number1 == number2 )
Console.WriteLine( "{0} == {1}", number1, number2 );
if ( number1 != number2 )
Console.WriteLine( "{0} != {1}", number1, number2 );
if ( number1 < number2 )
Console.WriteLine( "{0} < {1}", number1, number2 );
if ( number1 > number2 )
Console.WriteLine( "{0} > {1}", number1, number2 );
if ( number1 <= number2 )
Console.WriteLine( "{0} <= {1}", number1, number2 );
if ( number1 >= number2 )
Console.WriteLine( "{0} >= {1}", number1, number2 );
}
}
Related examples in the same category