Tsallaka zuwa abun ciki
Justice Tech School

C# Arithmetic Operators

Use + - * / and % for the remainder. Dividing two ints gives an int. ++ and -- add or subtract one. Math.Pow, Math.Sqrt and Math.Round help with more.

Example
int a = 17, b = 5;
Console.WriteLine($"{a + b} {a - b} {a * b} {a / b} {a % b}");
Console.WriteLine(17 / 5.0);
Console.WriteLine(Math.Pow(2, 10));

Exercise

Remainder operator.

17  5

Quiz Test

What is 17 / 5 with ints?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.