šŸ•·ļø Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 106 (from laksa070)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ā„¹ļø Skipped - page is already crawled

šŸ“„
INDEXABLE
āœ…
CRAWLED
5 days ago
šŸ¤–
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.includehelp.com/cpp-tutorial/assignments-operators-in-c-cpp.aspx
Last Crawled2026-04-11 21:38:39 (5 days ago)
First Indexed2020-06-07 11:42:57 (5 years ago)
HTTP Status Code200
Meta TitleAssignment Operators in C/C++
Meta DescriptionC/C++ | Assignment Operators: In this tutorial, we will learn about the various types of assignment operators with their usages, syntax, examples, etc.
Meta Canonicalnull
Boilerpipe Text
Home Ā» C++ programming language C/C++ | Assignment Operators : In this tutorial, we will learn about the various types of assignment operators with their usages, syntax, examples, etc. Submitted by IncludeHelp , on June 06, 2020 What are Assignment Operators in C/C++? Assignment operators are used to assign the value/result of the expression to a variable (constant – in case of constant declaration ). While executing an assignment operator based statement, it assigns the value (or the result of the expression) which is written at the right side to the variable which is written on the left side. Syntax variable = value; Type of the assignment operators C/C++ language provides a simple assignment operator that is "=" , but some of the other assignment operators (which are the combination of assignment and other operators) can be used. The assignment operators are, SNo. Operator Description Example 1 = Simple assignment operator x = 10 2 += Add and assignment operator x += 10 3 -= Subtract and assignment operator x -=10 4 *= Multiply and assignment operator x *=10 5 /= Divide and assignment operator x /=10 6 %= Modules and assignment operator x %=10 7 <<= Left shift and assignment operator x <<= 10 8 >>= Right shift and assignment operator x =>>10 9 &= Bitwise AND and assignment operator x &= 10 10 |= Bitwise OR and assignment operator x |= 10 11 ^| Bitwise XOR and assignment operator x ^= 10 Note: On the right side, a value, expression, or any variable can be used. 1) Simple assignment operator (=) It is a simple assignment operator which is used to assign the value and the result of the expression to the variable. Syntax variable = value; Example // C++ program to demonstrate the // example of = operator #include <iostream> using namespace std; int main () { int x = 0 ; x = 10 ; cout << "value of x = " << x << endl; return 0 ; } Output: value of x = 10 2) Add and assignment operator (+=) It adds the value or result of the expression to the current value of the variable and assigns the result to the variable. Syntax variable += value; equivalent to: variable = variable + value; Example // C++ program to demonstrate the // example of += operator #include <iostream> using namespace std; int main () { int x = 10 ; cout << "Before the operation, x = " << x << endl; x += 5 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 15 3) Subtract and assignment operator (-=) It subtracts the value or result of the expression to the current value of the variable and assigns the result to the variable. Syntax variable -= value; equivalent to: variable = variable - value; Example // C++ program to demonstrate the // example of -= operator #include <iostream> using namespace std; int main () { int x = 10 ; cout << "Before the operation, x = " << x << endl; x -= 5 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 5 4) Multiply and assignment operator (*=) It multiplies the value or result of the expression to the current value of the variable and assigns the result to the variable. Syntax variable *= value; equivalent to: variable = variable * value; Example // C++ program to demonstrate the // example of *= operator #include <iostream> using namespace std; int main () { int x = 10 ; cout << "Before the operation, x = " << x << endl; x *= 5 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 50 5) Divide and assignment operator (/=) It divides the value or result of the expression with the current value of the variable and assigns the result (quotient) to the variable. Syntax variable /= value; equivalent to: variable = variable / value; Example // C++ program to demonstrate the // example of /= operator #include <iostream> using namespace std; int main () { int x = 10 ; cout << "Before the operation, x = " << x << endl; x /= 5 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 2 6) Modules and assignment operator (%=) It divides the value or result of the expression with the current value of the variable and assigns the result (remainder) to the variable. Syntax variable %= value; equivalent to: variable = variable % value; Example // C++ program to demonstrate the // example of %= operator #include <iostream> using namespace std; int main () { int x = 10 ; cout << "Before the operation, x = " << x << endl; x %= 5 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 0 7) Left shift and assignment operator (<<=) It shifts the value of the variable by given number of bits (value) to the left and assigns the result to the variable. Syntax variable <<= value; equivalent to: variable = variable << value; Example // C++ program to demonstrate the // example of <<= operator #include <iostream> using namespace std; int main () { int x = 0x0A ; cout << "Before the operation, x = " << x << endl; x <<= 0x02 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 40 8) Right shift and assignment operator (>>=) It shifts the value of the variable by the given number of bits (value) to the right and assigns the result to the variable. Syntax variable >>= value; equivalent to: variable = variable >> value; Example // C++ program to demonstrate the // example of >>= operator #include <iostream> using namespace std; int main () { int x = 0x0A ; cout << "Before the operation, x = " << x << endl; x >>= 0x02 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 2 9) Bitwise AND and assignment operator (&=) It performs the Bitwise AND (&) operation on the existing value of the variable with the given value and assigns the result to the variable. Syntax variable &= value; equivalent to: variable = variable & value; Example // C++ program to demonstrate the // example of &= operator #include <iostream> using namespace std; int main () { int x = 0x0A ; cout << "Before the operation, x = " << x << endl; x &= 0x02 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 2 10) Bitwise OR and assignment operator (|=) It performs the Bitwise OR (|) operation on the existing value of the variable with the given value and assigns the result to the variable. Syntax variable |= value; equivalent to: variable = variable | value; Example // C++ program to demonstrate the // example of |= operator #include <iostream> using namespace std; int main () { int x = 0x0A ; cout << "Before the operation, x = " << x << endl; x |= 0x02 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 10 11) Bitwise XOR and assignment operator (^=) It performs the Bitwise XOR (^) operation on the existing value of the variable with the given value and assigns the result to the variable. Syntax variable ^= value; equivalent to: variable = variable ^ value; Example // C++ program to demonstrate the // example of ^= operator #include <iostream> using namespace std; int main () { int x = 0x0A ; cout << "Before the operation, x = " << x << endl; x ^= 0x02 ; cout << "After the operation, x = " << x << endl; return 0 ; } Output: Before the operation, x = 10 After the operation, x = 8 C++ program to demonstrate the example of various assignment operators // C++ program to demonstrate the example // of various assignment operators #include <iostream> using namespace std; int main () { int x = 0 ; // = operator x = 20 ; cout << "x = " << x << endl; // += operator x += 5 ; cout << "x = " << x << endl; // -= operator x -= 5 ; cout << "x = " << x << endl; // *= operator x *= 5 ; cout << "x = " << x << endl; // /= operator x /= 3 ; cout << "x = " << x << endl; // %= operator x %= 5 ; cout << "x = " << x << endl; // <<= operator x <<= 5 ; cout << "x = " << x << endl; // >>= operator x >>= 5 ; cout << "x = " << x << endl; // &= operator x &= 5 ; cout << "x = " << x << endl; // |= operator x |= 5 ; cout << "x = " << x << endl; // ^= operator x ^= 10 ; cout << "x = " << x << endl; return 0 ; } Output: x = 20 x = 25 x = 20 x = 100 x = 33 x = 3 x = 96 x = 3 x = 1 x = 5 x = 15 Advertisement Advertisement Learn & Test Your Skills
Markdownnull
Readable Markdown
[Home](https://www.includehelp.com/) Ā» [C++ programming language](https://www.includehelp.com/cpp-tutorial) **C/C++ \| Assignment Operators**: In this tutorial, we will learn about the various types of assignment operators with their usages, syntax, examples, etc. Submitted by **IncludeHelp**, on June 06, 2020 ## What are Assignment Operators in C/C++? **Assignment operators** are used to assign the value/result of the expression to a variable (constant – in case of [constant declaration](https://www.includehelp.com/cpp-tutorial/difference-between-const-and-define.aspx)). While executing an assignment operator based statement, it assigns the value (or the result of the expression) which is written at the right side to the variable which is written on the left side. ## Syntax ``` variable = value; ``` ## Type of the assignment operators C/C++ language provides a **simple assignment operator** that is **"="**, but some of the other **assignment operators** (which are the combination of assignment and other operators) can be used. The assignment operators are, | | | | | |---|---|---|---| | SNo. | Operator | Description | Example | | 1 | **\=** | Simple assignment operator | x = 10 | | 2 | **\+=** | Add and assignment operator | x += 10 | | 3 | **\-=** | Subtract and assignment operator | x -=10 | | 4 | **\*=** | Multiply and assignment operator | x \*=10 | | 5 | /= | Divide and assignment operator | x /=10 | | 6 | **%=** | Modules and assignment operator | x %=10 | | 7 | **\<\<=** | Left shift and assignment operator | x \<\<= 10 | | 8 | **\>\>=** | Right shift and assignment operator | x =\>\>10 | | 9 | **&=** | Bitwise AND and assignment operator | x &= 10 | | 10 | **\|=** | Bitwise OR and assignment operator | x \|= 10 | | 11 | **^\|** | Bitwise XOR and assignment operator | x ^= 10 | **Note:** On the right side, a value, expression, or any variable can be used. ## 1\) Simple assignment operator (=) It is a simple assignment operator which is used to assign the value and the result of the expression to the variable. ### Syntax ``` variable = value; ``` ### Example ``` // C++ program to demonstrate the // example of = operator #include <iostream> using namespace std; int main() { int x = 0; x = 10; cout << "value of x = " << x << endl; return 0; } ``` **Output:** ``` value of x = 10 ``` ## 2\) Add and assignment operator (+=) It adds the value or result of the expression to the current value of the variable and assigns the result to the variable. ### Syntax ``` variable += value; equivalent to: variable = variable + value; ``` ### Example ``` // C++ program to demonstrate the // example of += operator #include <iostream> using namespace std; int main() { int x = 10; cout << "Before the operation, x = " << x << endl; x += 5; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 15 ``` ## 3\) Subtract and assignment operator (-=) It subtracts the value or result of the expression to the current value of the variable and assigns the result to the variable. ### Syntax ``` variable -= value; equivalent to: variable = variable - value; ``` ### Example ``` // C++ program to demonstrate the // example of -= operator #include <iostream> using namespace std; int main() { int x = 10; cout << "Before the operation, x = " << x << endl; x -= 5; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 5 ``` ## 4\) Multiply and assignment operator (\*=) It multiplies the value or result of the expression to the current value of the variable and assigns the result to the variable. ### Syntax ``` variable *= value; equivalent to: variable = variable * value; ``` ### Example ``` // C++ program to demonstrate the // example of *= operator #include <iostream> using namespace std; int main() { int x = 10; cout << "Before the operation, x = " << x << endl; x *= 5; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 50 ``` ## 5\) Divide and assignment operator (/=) It divides the value or result of the expression with the current value of the variable and assigns the result (quotient) to the variable. ### Syntax ``` variable /= value; equivalent to: variable = variable / value; ``` ### Example ``` // C++ program to demonstrate the // example of /= operator #include <iostream> using namespace std; int main() { int x = 10; cout << "Before the operation, x = " << x << endl; x /= 5; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 2 ``` ## 6\) Modules and assignment operator (%=) It divides the value or result of the expression with the current value of the variable and assigns the result (remainder) to the variable. ### Syntax ``` variable %= value; equivalent to: variable = variable % value; ``` ### Example ``` // C++ program to demonstrate the // example of %= operator #include <iostream> using namespace std; int main() { int x = 10; cout << "Before the operation, x = " << x << endl; x %= 5; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 0 ``` ## 7\) Left shift and assignment operator (\<\<=) It shifts the value of the variable by given number of bits (value) to the left and assigns the result to the variable. ### Syntax ``` variable <<= value; equivalent to: variable = variable << value; ``` ### Example ``` // C++ program to demonstrate the // example of <<= operator #include <iostream> using namespace std; int main() { int x = 0x0A; cout << "Before the operation, x = " << x << endl; x <<= 0x02; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 40 ``` ## 8\) Right shift and assignment operator (\>\>=) It shifts the value of the variable by the given number of bits (value) to the right and assigns the result to the variable. ### Syntax ``` variable >>= value; equivalent to: variable = variable >> value; ``` ### Example ``` // C++ program to demonstrate the // example of >>= operator #include <iostream> using namespace std; int main() { int x = 0x0A; cout << "Before the operation, x = " << x << endl; x >>= 0x02; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 2 ``` ## 9\) Bitwise AND and assignment operator (&=) It performs the Bitwise AND (&) operation on the existing value of the variable with the given value and assigns the result to the variable. ### Syntax ``` variable &= value; equivalent to: variable = variable & value; ``` ### Example ``` // C++ program to demonstrate the // example of &= operator #include <iostream> using namespace std; int main() { int x = 0x0A; cout << "Before the operation, x = " << x << endl; x &= 0x02; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 2 ``` ## 10\) Bitwise OR and assignment operator (\|=) It performs the Bitwise OR (\|) operation on the existing value of the variable with the given value and assigns the result to the variable. ### Syntax ``` variable |= value; equivalent to: variable = variable | value; ``` ### Example ``` // C++ program to demonstrate the // example of |= operator #include <iostream> using namespace std; int main() { int x = 0x0A; cout << "Before the operation, x = " << x << endl; x |= 0x02; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 10 ``` ## 11\) Bitwise XOR and assignment operator (^=) It performs the Bitwise XOR (^) operation on the existing value of the variable with the given value and assigns the result to the variable. ### Syntax ``` variable ^= value; equivalent to: variable = variable ^ value; ``` ### Example ``` // C++ program to demonstrate the // example of ^= operator #include <iostream> using namespace std; int main() { int x = 0x0A; cout << "Before the operation, x = " << x << endl; x ^= 0x02; cout << "After the operation, x = " << x << endl; return 0; } ``` **Output:** ``` Before the operation, x = 10 After the operation, x = 8 ``` **C++ program to demonstrate the example of various assignment operators** ``` // C++ program to demonstrate the example // of various assignment operators #include <iostream> using namespace std; int main() { int x = 0; // = operator x = 20; cout << "x = " << x << endl; // += operator x += 5; cout << "x = " << x << endl; // -= operator x -= 5; cout << "x = " << x << endl; // *= operator x *= 5; cout << "x = " << x << endl; // /= operator x /= 3; cout << "x = " << x << endl; // %= operator x %= 5; cout << "x = " << x << endl; // <<= operator x <<= 5; cout << "x = " << x << endl; // >>= operator x >>= 5; cout << "x = " << x << endl; // &= operator x &= 5; cout << "x = " << x << endl; // |= operator x |= 5; cout << "x = " << x << endl; // ^= operator x ^= 10; cout << "x = " << x << endl; return 0; } ``` **Output:** ``` x = 20 x = 25 x = 20 x = 100 x = 33 x = 3 x = 96 x = 3 x = 1 x = 5 x = 15 ``` Advertisement Advertisement **Learn & Test Your Skills**
Shard106 (laksa)
Root Hash1184066710662109106
Unparsed URLcom,includehelp!www,/cpp-tutorial/assignments-operators-in-c-cpp.aspx s443