โน๏ธ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.4 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.includehelp.com/cpp-tutorial/arithmetic-operators-in-c-cpp.aspx |
| Last Crawled | 2026-03-25 18:07:41 (12 days ago) |
| First Indexed | 2020-06-03 07:30:53 (5 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Arithmetic Operators in C/C++ |
| Meta Description | C/C++ programming Arithmetic Operators: In this tutorial, we are going to learn about the various arithmetic operators with their usages, syntaxes and examples. |
| Meta Canonical | null |
| Boilerpipe Text | Home
ยป
C++ programming language
C/C++ programming Arithmetic Operators
: In this tutorial, we are going to learn about the various arithmetic operators with their usages, syntaxes and examples.
Submitted by
IncludeHelp
, on June 02, 2020
What are Arithmetic Operators in C/C++?
Arithmetic operators
are the special symbols that are used for the Arithmetic / Mathematical operations. These operators can be unary and binary.
Following are the
types of Arithmetic Operators
,
Arithmetic unary operators
Arithmetic binary operators
Arithmetic unary operators
For the unary operations โ we need only one operand. These are the operators,
Unary plus (+)
Unary minus (-)
Syntax
+a
-a
Example
Input:
int a = -10;
Operation & Output:
+a = -10
-a = 10
C++ program to demonstrate the example of arithmetic unary operators
#
include
<
iostream
>
using
namespace
std
;
int
main
(
)
{
int
a
=
10
;
int
b
=
-
10
;
// printing the values
cout
<
<
"
a:
"
<
<
a
<
<
endl
;
cout
<
<
"
b:
"
<
<
b
<
<
endl
;
// unary plus operations
cout
<
<
"
+a:
"
<
<
+
a
<
<
endl
;
cout
<
<
"
+b:
"
<
<
+
b
<
<
endl
;
// unary minus operations
cout
<
<
"
-a:
"
<
<
-
a
<
<
endl
;
cout
<
<
"
-b:
"
<
<
-
b
<
<
endl
;
return
0
;
}
Output:
a: 10
b: -10
+a: 10
+b: -10
-a: -10
-b: 10
Arithmetic binary operators
For the binary operations โ we need two operands. These are the operators,
Operator
Name
Description
+
Plus operator
Returns the addition of two operands.
-
Minus operator
Returns the subtraction of two operands.
*
Multiplication operator
Returns the multiplication (product) of two operands.
/
Divide operator
Returns the result of the division of two operands i.e. returns the quotient of the division operation.
%
Modulus operator
Returns the remainder of the division operation on two operands.
Syntax
a + b
a - b
a * b
a / b
a % b
Example
Input:
int a = 10;
int b = 3;
Operation & Output:
a + b = 13
a - b = 7
a * b = 30
a / b = 3
a % b = 1
C++ program to demonstrate the example of arithmetic binary operators
#
include
<
iostream
>
#
include
<
cmath
>
// for fmod() func.
using
namespace
std
;
int
main
(
)
{
int
a
=
10
;
int
b
=
3
;
// printing the values
cout
<
<
"
a :
"
<
<
a
<
<
endl
;
cout
<
<
"
b :
"
<
<
b
<
<
endl
;
// arithmetic operations
cout
<
<
"
a + b :
"
<
<
a
+
b
<
<
endl
;
cout
<
<
"
a - b :
"
<
<
a
-
b
<
<
endl
;
cout
<
<
"
a * b :
"
<
<
a
*
b
<
<
endl
;
cout
<
<
"
a / b :
"
<
<
a
/
b
<
<
endl
;
cout
<
<
"
a % b :
"
<
<
a
%
b
<
<
endl
;
cout
<
<
endl
;
float
x
=
10.23
f
;
float
y
=
3.10
f
;
// printing the values
cout
<
<
"
x :
"
<
<
x
<
<
endl
;
cout
<
<
"
y :
"
<
<
y
<
<
endl
;
// arithmetic operations
cout
<
<
"
x + y :
"
<
<
x
+
y
<
<
endl
;
cout
<
<
"
x - y :
"
<
<
x
-
y
<
<
endl
;
cout
<
<
"
x * y :
"
<
<
x
*
y
<
<
endl
;
cout
<
<
"
x / y :
"
<
<
x
/
y
<
<
endl
;
// % operator doesn't work with float values
// use fmod() for this
// cout << "x % y : " << x % y << endl;
cout
<
<
"
fmod(
"
<
<
x
<
<
"
,
"
<
<
y
<
<
"
) :
"
<
<
fmod
(
x
,
y
)
<
<
endl
;
return
0
;
}
Output:
a : 10
b : 3
a + b : 13
a - b : 7
a * b : 30
a / b : 3
a % b : 1
x : 10.23
y : 3.1
x + y : 13.33
x - y : 7.13
x * y : 31.713
x / y : 3.3
fmod(10.23 , 3.1) : 0.93
Advertisement
Advertisement |
| Markdown | null |
| Readable Markdown | [Home](https://www.includehelp.com/) ยป [C++ programming language](https://www.includehelp.com/cpp-tutorial)
**C/C++ programming Arithmetic Operators**: In this tutorial, we are going to learn about the various arithmetic operators with their usages, syntaxes and examples.
Submitted by **IncludeHelp**, on June 02, 2020
## What are Arithmetic Operators in C/C++?
**Arithmetic operators** are the special symbols that are used for the Arithmetic / Mathematical operations. These operators can be unary and binary.
Following are the **types of Arithmetic Operators**,
- Arithmetic unary operators
- Arithmetic binary operators
## Arithmetic unary operators
For the unary operations โ we need only one operand. These are the operators,
1. Unary plus (+)
2. Unary minus (-)
### Syntax
```
+a
-a
```
### Example
```
Input:
int a = -10;
Operation & Output:
+a = -10
-a = 10
```
### C++ program to demonstrate the example of arithmetic unary operators
```
#include <iostream>
using namespace std;
int main()
{
int a = 10;
int b = -10;
// printing the values
cout << "a: " << a << endl;
cout << "b: " << b << endl;
// unary plus operations
cout << "+a: " << +a << endl;
cout << "+b: " << +b << endl;
// unary minus operations
cout << "-a: " << -a << endl;
cout << "-b: " << -b << endl;
return 0;
}
```
**Output:**
```
a: 10
b: -10
+a: 10
+b: -10
-a: -10
-b: 10
```
## Arithmetic binary operators
For the binary operations โ we need two operands. These are the operators,
| Operator | Name | Description |
|---|---|---|
| \+ | Plus operator | Returns the addition of two operands. |
| \- | Minus operator | Returns the subtraction of two operands. |
| \* | Multiplication operator | Returns the multiplication (product) of two operands. |
| / | Divide operator | Returns the result of the division of two operands i.e. returns the quotient of the division operation. |
| % | Modulus operator | Returns the remainder of the division operation on two operands. |
### Syntax
```
a + b
a - b
a * b
a / b
a % b
```
### Example
```
Input:
int a = 10;
int b = 3;
Operation & Output:
a + b = 13
a - b = 7
a * b = 30
a / b = 3
a % b = 1
```
## C++ program to demonstrate the example of arithmetic binary operators
```
#include <iostream>
#include <cmath> // for fmod() func.
using namespace std;
int main()
{
int a = 10;
int b = 3;
// printing the values
cout << "a : " << a << endl;
cout << "b : " << b << endl;
// arithmetic operations
cout << "a + b : " << a + b << endl;
cout << "a - b : " << a - b << endl;
cout << "a * b : " << a * b << endl;
cout << "a / b : " << a / b << endl;
cout << "a % b : " << a % b << endl;
cout << endl;
float x = 10.23f;
float y = 3.10f;
// printing the values
cout << "x : " << x << endl;
cout << "y : " << y << endl;
// arithmetic operations
cout << "x + y : " << x + y << endl;
cout << "x - y : " << x - y << endl;
cout << "x * y : " << x * y << endl;
cout << "x / y : " << x / y << endl;
// % operator doesn't work with float values
// use fmod() for this
// cout << "x % y : " << x % y << endl;
cout << "fmod(" << x << " , " << y << ") : " << fmod(x, y) << endl;
return 0;
}
```
**Output:**
```
a : 10
b : 3
a + b : 13
a - b : 7
a * b : 30
a / b : 3
a % b : 1
x : 10.23
y : 3.1
x + y : 13.33
x - y : 7.13
x * y : 31.713
x / y : 3.3
fmod(10.23 , 3.1) : 0.93
```
Advertisement
Advertisement |
| Shard | 106 (laksa) |
| Root Hash | 1184066710662109106 |
| Unparsed URL | com,includehelp!www,/cpp-tutorial/arithmetic-operators-in-c-cpp.aspx s443 |