Determine if a value is positive, negative, or zero : If : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » If »

 

Determine if a value is positive, negative, or zero









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Determine if a value is positive, negative, or zero. 
using System; 
 
public class PosNegZero {  
  public static void Main() { 
    int i; 
 
    for(i=-5; i <= 5; i++) { 
 
      Console.Write("Testing " + i + ": "); 
 
      if(i < 0) Console.WriteLine("negative"); 
      else if(i == 0) Console.WriteLine("no sign"); 
        else Console.WriteLine("positive"); 
    } 
 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» If