Demonstrate the relational and logical operators : Operators : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Operators »

 

Demonstrate the relational and logical operators









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Demonstrate the relational and logical operators. 
 
using System; 
 
public class RelLogOps {    
  public static void Main() {    
    int i, j; 
    bool b1, b2; 
 
    i = 10; 
    j = 11; 
    if(i < j) Console.WriteLine("i < j"); 
    if(i <= j) Console.WriteLine("i <= j"); 
    if(i != j) Console.WriteLine("i != j"); 
    if(i == j) Console.WriteLine("this won't execute"); 
    if(i >= j) Console.WriteLine("this won't execute"); 
    if(i > j) Console.WriteLine("this won't execute"); 
 
    b1 = true; 
    b2 = false; 
    if(b1 & b2) Console.WriteLine("this won't execute"); 
    if(!(b1 & b2)) Console.WriteLine("!(b1 & b2) is true"); 
    if(b1 | b2) Console.WriteLine("b1 | b2 is true"); 
    if(b1 ^ b2) Console.WriteLine("b1 ^ b2 is true"); 
  }    
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Operators