How to find the remainder in swift using modulo

Finding the remainder in swift :

In this tutorial, we will learn how to find the remainder in swift. Swift provides one operator % to find out the remainder. Let’s check how it works :

Remainder operator :

% is used to find out the remainder. It is also known as modulo operator. This operator is used like below :

first_number % second_number 

It will return the remainder after firstnumber_ is divided by the secondnumber_. For example :

print(4 % 2)

print(11 % 2)

print(1774 % 3)

It will print :


swift modulo

Note that we can use it only with integers, not with floating-point numbers.

Where is the color and why codevscolor ?

Long story short, I love paintings and I paint on weekends. We(me and my wife) have one Youtube channel. Below is a video that I did recently. If you love this please do subscribe to support us 😊