Use count number to control while loop : While : Statement C# Examples


C# Examples » Statement » While »

 

Use count number to control while loop









    
using  System;  
  
class  MainClass  {      
    public  static  void  Main()  {  
        int  num;  
        int  mag;  
  
        num  =  435679;  
        mag  =  0;  
  
        Console.WriteLine("Number:  "  +  num);  
  
        while(num  >  0)  {  
            mag++;  
            num  =  num  /  10;  
        };  
  
        Console.WriteLine("Magnitude:  "  +  mag);  
    }      
}
    
   
  
   



Output

Number: 435679
Magnitude: 6


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» While