C++ Arithmetic Operators

In C++, operators are symbols used to manipulate variables and values. They allow programs to perform calculations, comparisons, and logical evaluations.

Tutorials dojo strip



Using the Addition Operator (+)

Operators can be used to perform simple arithmetic operations. For example:

C++

This program adds 200 and 50, storing the result (250) in topSpeed.

Operators can also combine variables and values, or multiple variables:

C++




Types of Operators in C++

C++ organizes operators into different categories:

  • Arithmetic Operators → Perform mathematical calculations.
  • Assignment Operators → Assign values to variables.
  • Comparison Operators → Compare values.
  • Logical Operators → Control decision-making logic.
  • Bitwise Operators → Perform operations on binary values.




Arithmetic Operators

Arithmetic operators allow for common mathematical operations.

OperatorNameDescriptionExample
+AdditionAdds two valuesx + y
-SubtractionSubtracts one value from anotherx - y
*MultiplicationMultiplies two valuesx * y
/DivisionDivides one value by anotherx / y
%ModulusReturns the remainder of divisionx % y
++IncrementIncreases a variable’s value by 1++x
--DecrementDecreases a variable’s value by 1--x
Tutorials dojo strip