Comparing integers using if statements, equality operators, and relational operators. : int « Data Types « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Data Types » intScreenshots 
Comparing integers using if statements, equality operators, and relational operators.
 

       

using System;

public class Comparison
{
   public static void Mainstring[] args )
   {
      int number1; 
      int number2; 

      Console.Write"Enter first integer: " );
      number1 = Convert.ToInt32Console.ReadLine() );

      Console.Write"Enter second integer: " );
      number2 = Convert.ToInt32Console.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
1.Assign value to int variable
2.Call methods from primitive data types
3.Calculating the product of three integers.
4.demonstrates variablesdemonstrates variables
5.Assing value to int valueAssing value to int value
6.Calculate: int and doubleCalculate: int and double
7.Size of int, double, char and boolSize of int, double, char and bool
8.displays a conversion table of Fahrenheit to Celsiusdisplays a conversion      table of Fahrenheit to Celsius
9.Some Operator on int
10.Using Integers
11.Using Variables
12.Convert string value to integer by using the int.TryParse
13.Use CultureInfo int ToString method
14.Integer OverFlow
15.Catch OverflowException Exception
16.Do calculation with int variable
17.Format int in Console.WriteLine
18.Use CultureInfo in int.ToString method
19.Use #, % and in int format
20.int based Fahrenheit and Celsius (Centigrade) Scales
21.int array property
22.Parse int value
23.The precision specifier controls the number of significant digits or zeros to the right of a decimal:
24.Int value To Hex char
25.Get the digit-length of an int value
26.Max/Min for int and double values
27.Read sync safe int 32
28.Write Synch safe Int32
29.Calculate average for a list of integer values with params int[] values
30.Int extension Convert integer to boolean, is it even, is it positive
31.Converts an integer into a roman numeral.
32.Get Ordinal
33.Output with x8 format
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.