kartal - 1 year ago 80

C# Question

How can I calculate division and modulo for integer numbers in c#?

Answer Source

Before asking questions of this kind, please check MSDN documentation.

When you divide two integers, the result is always an integer. For example, the result of 5 / 2 is 2. To determine the remainder of 5 / 2, use the modulo operator (%).

```
int a = 5;
int b = 3;
int div = a / b; //div is 1
int mod = a % b; //mod is 2
```