Modulo / Remainder In Arduino - Tutorialspoint

  • Home
  • Whiteboard
  • Online Compilers
  • Practice
  • Articles
  • AI Assistant
  • Jobs
  • Tools
  • Corporate Training
  • Courses
  • Certifications
Menu Categories Login
  • Switch theme
  • SQL
  • HTML
  • CSS
  • Javascript
  • Python
  • Java
  • C
  • C++
  • PHP
  • Scala
  • C#
  • Tailwind CSS
  • Node.js
  • MySQL
  • MongoDB
  • PL/SQL
  • Swift
  • Bootstrap
  • R
  • Machine Learning
  • Blockchain
  • Angular
  • React Native
  • Computer Fundamentals
  • Compiler Design
  • Operating System
  • Data Structure and Algorithms
  • Computer Network
  • DBMS
  • Excel
Technical Questions and Answers
  • Data Structure Data Structure
  • Networking Networking
  • RDBMS RDBMS
  • Operating System Operating System
  • Java Java
  • MS Excel MS Excel
  • iOS iOS
  • HTML HTML
  • CSS CSS
  • Android Android
  • Python Python
  • C Programming C Programming
  • C++ C++
  • C# C#
  • MongoDB MongoDB
  • MySQL MySQL
  • Javascript Javascript
  • PHP PHP
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary
  • Who is Who
Modulo / Remainder in Arduino ArduinoArduino BoardsArduino IDEArduino Programming Language

The modulo operator in Arduino is exactly the same as in C language, or most other languages for that matter. The operator is %. The syntax is: a % b and it returns the remainder when a is divided by b.

Example

The following example illustrates the use of this operator −

void setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    Serial.println(10%3);    Serial.println(4%2);    Serial.println(50%9); } void loop() {    // put your main code here, to run repeatedly: }

Output

The Serial Monitor output is shown below. You can work out the remainders yourself and verify that the output is correct.

Yash Sanghvi Yash Sanghvi Updated on: 2021-05-31T14:16:04+05:30

8K+ Views

Tag » Arduino Quotient And Remainder