Arithmetic Operators in C++
Notes:
Arithmetic Operators in C++ Programming Language:
- C++ provides 5 arithmetic operators to perform arithmetic operations. They are
+: Addition Operator : sum of two numbers
- : Subtraction Operator : difference between two numbers
*: Multiplication Operator : product of two numbers
/: Division Operator : quotient of a complete division operation
%: Modulus Operator : remainder of a first division operation
Example Code:
#include <iostream>
using namespace std;
int main()
{
cout << 2 + 2 << endl; // 4
cout << 5 + 2 << endl; // 7
cout << 5 - 2 << endl; // 3
cout << 10 - 2 << endl; // 8
cout << 5 * 2 << endl; // 10
cout << 10 * 2 << endl; // 20
cout << 10 / 2 << endl; // 5
cout << 10 % 2 << endl; // 0
cout << 11 / (float)2 << endl; // 5.5
cout << 11 % 2 << endl; // 1
return 0;
}