Loop condition can be any bool expression. : For : Statement C# Examples


C# Examples » Statement » For »

 

Loop condition can be any bool expression.









    
using  System;  
  
class  MainClass  {        
    public  static  void  Main()  {        
        int  i,  j;  
        bool  done  =  false;  
  
        for(i=0,  j=100;  !done;  i++,  j--)  {  
  
            if(i*i  >=  j)  done  =  true;  
  
            Console.WriteLine("i,  j:  "  +  i  +  "  "  +  j);  
        }  
  
    }  
}
    
   
  
   



Output

i, j: 0 100
i, j: 1 99
i, j: 2 98
i, j: 3 97
i, j: 4 96
i, j: 5 95
i, j: 6 94
i, j: 7 93
i, j: 8 92
i, j: 9 91
i, j: 10 90


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» For