Back to Curriculum

6. Arithmetic Operators

Basic Arithmetic Operators

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).

Your Task

Calculate the area of a rectangle. Declare two variables: length and width, then calculate and store the area in a variable called area.

🎉

Lesson Complete!

Excellent! You now understand how to perform basic arithmetic operations in C++.

Continue to Lesson 7: Type Conversion
main.cpp
Output
Click "Check Answer" to run your code.