Mathematics in Processing
Basic Operations
Basic Operations:
Sample Code:
int numberOne = 20;
int numberTwo = 12;
int sum = numberOne + numberTwo;
println("The sum is " + sum);
int difference = numberOne - numberTwo;
println("The difference is " + difference);
int product = numberOne * numberTwo;
println("The product is " + product);
double quotient = numberOne / numberTwo;
println("The quotient is " + quotient);
int remainder = numberOne % numberTwo;
println("The remainder is " + remainder);
What is the output of this code? Why should quotient be data type double?
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%)
Sample Code:
int numberOne = 20;
int numberTwo = 12;
int sum = numberOne + numberTwo;
println("The sum is " + sum);
int difference = numberOne - numberTwo;
println("The difference is " + difference);
int product = numberOne * numberTwo;
println("The product is " + product);
double quotient = numberOne / numberTwo;
println("The quotient is " + quotient);
int remainder = numberOne % numberTwo;
println("The remainder is " + remainder);
What is the output of this code? Why should quotient be data type double?