Skip to content

Instantly share code, notes, and snippets.

@techzeero
Created February 23, 2020 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techzeero/46926db68ea9e689fdbd06a03c7a04c0 to your computer and use it in GitHub Desktop.
Save techzeero/46926db68ea9e689fdbd06a03c7a04c0 to your computer and use it in GitHub Desktop.
/*
Arduino Arithmetic Operators
For more details, visit: https://techzeero.com/arduino-tutorials/arduino-arithmetic-operators/
*/
void setup() {
int a = 2;
int b = 3;
int result;
float result_fl;
Serial.begin(9600);
Serial.print("Addition of (a + b): ");
result = a + b;
Serial.println(result);
Serial.print("Subtraction (5 - 3): ");
result = 5 - 3;
Serial.println(result);
Serial.print("Multiplication (6 * 3): ");
result = 6 * 3;
Serial.println(result);
Serial.print("Int Division (3 / 2): ");
result = 3 / 2;
Serial.println(result);
Serial.print("Float Division (3.0 / 2.0): ");
result_fl = 3.0 / 2.0;
Serial.println(result_fl);
Serial.print("Remainder (10 % 4): ");
result = 10 % 4;
Serial.println(result);
Serial.print("2 Power of 3: ");
result = pow(3,2);
Serial.println(result);
Serial.print("Square Root of 5: ");
Serial.println(sqrt(5));
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment