Arduino Programming Language: Modulo

Name

% (modulo)

Description

Calculates the remainder when one integer is divided by another. It is useful for keeping a variable within a particular range (e.g. the size of an array).

Syntax

res=dividend%divisor;

Parameters

  • dividend: the number to be divided
  • divisor: the number to divide by

Returns

int 

Usage

Applications

Examples

int a=10;
int b=3;
int c;
c=a%3; //return 1

Related Functions


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc