C++ provides several arithmetic operators for performing mathematical calculations:
+
Addition-
Subtraction*
Multiplication/
Division%
Modulus (remainder)int a = 10;
int b = 3;
int sum = a + b; // 13
int difference = a - b; // 7
int product = a * b; // 30
int quotient = a / b; // 3 (integer division)
int remainder = a % b; // 1
Note: When dividing integers, the result is also an integer (truncated, not rounded).
Calculate the area of a rectangle. Declare two variables: length
and width
, then calculate and store the area in a variable called area
.
Click "Check Answer" to run your code.