Arithmetic Operators the symbols that are used to perform mathematical operations on operands such as addition, subtraction, multiplication, division etc.
| operator | description |
|---|---|
+ | addition adds two operands. eg, a+b. |
- | subtraction subtracts two operands. eg, a-b. |
* | multiplication multiplies two operands. eg, a*b. |
/ | division divides the operand by the second. eg, a/b. |
% | modulo returns the remainder when the first operand is divided by the second. For example, a%b. |
Example: C++ program for the Arithmetic operators.
#include <iostream>
using namespace std;
int main()
{
int a = 12;
int b = 5;
int result;
result = a + b;
cout << "Addition Result: " << result << endl;
result = a - b;
cout << "Subtraction Result: " << result << endl;
result = a * b;
cout << "Multiplication Result: " << result << endl;
result = a / b;
cout << "Division Result: " << result << endl;
result = a % b;
cout << "modulo Result: " << result << endl;
return 0;
}
Output: Result of Arithmetic Operators in C++
Addition Result: 17
Subtraction Result: 7
Multiplication Result: 60
Division Result: 2
modulo Result: 2