Use % operator to get remainder : Remainder Operator : Operator C# Examples


C# Examples » Operator » Remainder Operator »

 

Use % operator to get remainder









    
using  System;  
  
class  Example  {        
    public  static  void  Main()  {        
        int  iresult,  irem;  
        double  dresult,  drem;  
  
        iresult  =  10  /  3;  
        irem  =  10  %  3;  
  
        dresult  =  10.0  /  3.0;  
        drem  =  10.0  %  3.0;    
  
        Console.WriteLine("Result  and  remainder  of  10  /  3:  "  +  
                                              iresult  +  "  "  +  irem);  
        Console.WriteLine("Result  and  remainder  of  10.0  /  3.0:  "  +  
                                              dresult  +  "  "  +  drem);  
    }        
}
    
   
  
   



Output

Result and remainder of 10 / 3: 3 1
Result and remainder of 10.0 / 3.0: 3.33333333333333 1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Operator
» Remainder Operator