In C++, arithmetic operations are the basic mathematical calculations that help in performing everything from simple math to complex algorithms. Whether you’re building a game, calculator, or billing system—these operators are your building blocks.

Let’s learn the main arithmetic operators in C++, their syntax, output, and how they work .


1. Addition (+)

Code Example:

 Explanation like a teacher:

·      We declared two integers a = 5 and b = 3.

·      Then we added them using a + b.

·      The result is stored in result.

Output:




 2. Subtraction (-)

Code Example:

 Explanation:

·      10 minus 4 equals 6.

·      It subtracts the second number from the first.

 Output:


3. Multiplication (*)

Code Example:

 Explanation:

·      6 times 7 equals 42.

·      We used * for multiplication.

 Output:


 4. Division (/)

Code Example:

cpp

 Explanation:

·      10 divided by 2 equals 5.

·      It performs integer division in C++, so result is whole number.

 Output:

note: If b = 3, then 10 / 3 would give 3 (not 3.33), because both are integers.


 5. Modulus (%)

Code Example:

 Explanation:

·      % gives the remainder.

·      10 divided by 3 = 3 remainder 1.

 Output:


 6. Increment (++) and Decrement (--)

Increment Example:

 Explanation:

·      a++ adds 1 to a.

·      So, 5 becomes 6.

 Output:

Decrement Example:

 Explanation:

·      a-- subtracts 1.

·      So, 5 becomes 4.

Output:


S 7. Compound Arithmetic Operators

You can also combine arithmetic and assignment:

Operator

Meaning

Example

Equivalent To

+=

Add and assign

a += 5;

a = a + 5;

-=

Subtract and assign

a -= 2;

a = a - 2;

*=

Multiply and assign

a *= 3;

a = a * 3;

/=

Divide and assign

a /= 2;

a = a / 2;



 Order of Arithmetic Operations (Precedence)

C++ follows BODMAS like maths:

 Explanation:

·      Multiplication happens first: 3 * 4 = 12

·      Then addition: 2 + 12 = 14

 Output:

Use parentheses to change the order:



Common Mistakes to Avoid

1.    ❌ Dividing by zero – causes crash or runtime error

2.    ❌ Mixing float and int without casting

3.    ❌ Assuming % works with floats (in C++, it doesn’t)


 Practice Tip (like a teacher would say):

Try changing values in the code and predict the output before running. It helps in strengthening logic and understanding how each operator behaves.


 Conclusion

Arithmetic operations in C++ are easy to learn but crucial for every program you write. Once you master how each operator works, you'll be able to build logic in games, financial apps, AI models, and beyond.