How to calculate divide and modulo of integers in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int a = 5;
        int b = 3;

        int div = a / b; 
        int mod = a % b; 
        
        Console.WriteLine(div);
        Console.WriteLine(mod);
        
        Console.WriteLine();
        
        Console.WriteLine((int)(100 / 26));
        Console.WriteLine((int)(100 % 26));
    }
}




/*
run:
    
1
2

3
22
    
*/

 



answered Jan 7, 2022 by avibootz

Related questions

...