How to find the remainder in swift using modulo

Published by admin on

Swift find the remainder 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 first_number is divided by the second_number. 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.

Categories: swift


Leave a Reply

Your email address will not be published. Required fields are marked *