🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 28 (from laksa059)

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
1 month ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH1.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.educative.io/answers/what-are-assignment-operators-in-cpp
Last Crawled2026-03-08 13:26:43 (1 month ago)
First Indexed2022-12-21 03:47:30 (3 years ago)
HTTP Status Code200
Meta TitleWhat are assignment operators in C++?
Meta DescriptionContributor: Onyejiaku Theophilus Chidalu
Meta Canonicalnull
Boilerpipe Text
#include <iostream> using namespace std; int main() { int a=21; int c; // using the simple assignment operator c=a; cout << "Line 1: -= operator, value of c= "<<c<<endl; // using the add and assignment operator c+=a; cout << "Line 2: += operator, value of c= "<<c<<endl; // using the subtract and assignment operator c-=a; cout << "Line 3: -= operator, value of c= "<<c<<endl; // using the multiply and assignment operator c*=a; cout << "Line 4: *= operator, value of c= "<<c<<endl; // using the divide and assignment operator c/=a; cout << "Line 5: /= operator, value of c= "<<c<<endl; // lets give c another value c=200; // using the modulo and assignment operator c%=a; cout << "Line 6: %= operator, value of c= "<<c<<endl; // using the left shift and assignment operator c<<=2; cout << "Line 7: <<= operator, value of c= "<<c<<endl; // using the right shift and assignment operator c>>=2; cout << "Line 8: >>= operator, value of c= "<<c<<endl; // // using the bitwise and assignment operator c&=2; cout << "Line 9: &= operator, value of c= "<<c<<endl; // using the bitwise exclusive or and assignment operator c^=2; cout << "Line 10: ^= operator, value of c= "<<c<<endl; // using the bitwise inclusive or and assignment operator c|=2; cout << "Line 11: |= operator, value of c=: "<<c<<endl; return 0; }
Markdown
Explore EXPLORE THE CATALOGSupercharge your career with 700+ hands-on courses View All Courses Python Java JavaScript C React Docker Vue JS R Web Dev DevOps AWS C\# LEARNING TOOLSExplore the industry's most complete learning platform CoursesLevel up your skills Skill PathsAchieve learning goals ProjectsBuild real-world applications Mock InterviewsNewAI-Powered interviews Personalized PathsGet the right resources for your goals LEARN TO CODE Check out our beginner friendly courses. Pricing For Business Resources [NewsletterCurated insights on AI, Cloud & System Design](https://www.educative.io/newsletter) [BlogFor developers, By developers](https://www.educative.io/blog) [Free CheatsheetsDownload handy guides for tech topics](https://www.educative.io/cheatsheets) [AnswersTrusted answers to developer questions](https://www.educative.io/answers) [GamesSharpen your skills with daily challenges](https://www.educative.io/games) Search Courses Log In Join for free # What are assignment operators in C++? ## ### Overview **Assignment operators** are used to assign a value to a variable. The left side operand of the assignment operator is a *variable* and the right side operand of the assignment operator is a *value*. For example, the expression `C+=2` simply means that `"C"` is the *variable*, the `"+="` is the *assignment operator*, and lastly the `"2"` is the *value* assigned to the variable. Assignment operators supported by C++ language are shown in the table below. | Operator | Description | Example | |---|---|---| | `=` | Simple assignment operator. It assigns values from right operands to the left side operand | C=A+B will assign value of A+B into C | | `+=` | Add AND assignment operator. It adds the right operand to the left operand and assigns the result to the left operand | C+=A is equivalent to C=C+A | | `-=` | Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. | C-=A is equivalent to C=C-A | | `*+` | Multiply AND assignment operator. It multiplies the right operand with the left operand and assigns the result to the left operand. | C\*=A is equivalent to C=C\*A | | `/=` | Divides AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand. | C/=A is equivalent to C=C/A | | `%=` | Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand. | C%=A is equivalent to C=C%A | | `<<=` | Left shift AND assignment operator. | C\<\<=2 is same as C=C\<\<2 | | `>>=` | Right shift AND assignment operator | C=C\>\>2 is same as C=C\>\>2 | | `&=` | Bitwise AND assignment operator | C&=2 is same as C=C&2 | | `^=` | Bitwise exclusive OR AND assignment operator | C^=2 is same as C=C^2 | | `|=` | Bitwise inclusive OR AND assignment operator | C | ### Using the assignment operators Let’s write a code to include all the assignment operators. ### Code ``` #include <iostream>using namespace std;int main() {int a=21;int c;// using the simple assignment operatorc=a;cout << "Line 1: -= operator, value of c= "<<c<<endl;// using the add and assignment operatorc+=a;cout << "Line 2: += operator, value of c= "<<c<<endl;// using the subtract and assignment operatorc-=a;cout << "Line 3: -= operator, value of c= "<<c<<endl;// using the multiply and assignment operatorc*=a;cout << "Line 4: *= operator, value of c= "<<c<<endl;// using the divide and assignment operatorc/=a;cout << "Line 5: /= operator, value of c= "<<c<<endl;// lets give c another valuec=200;// using the modulo and assignment operatorc%=a;cout << "Line 6: %= operator, value of c= "<<c<<endl;// using the left shift and assignment operatorc<<=2;cout << "Line 7: <<= operator, value of c= "<<c<<endl;// using the right shift and assignment operatorc>>=2;cout << "Line 8: >>= operator, value of c= "<<c<<endl;// // using the bitwise and assignment operatorc&=2;cout << "Line 9: &= operator, value of c= "<<c<<endl;// using the bitwise exclusive or and assignment operatorc^=2;cout << "Line 10: ^= operator, value of c= "<<c<<endl;// using the bitwise inclusive or and assignment operatorc|=2;cout << "Line 11: |= operator, value of c=: "<<c<<endl;return 0;} ``` Run ### Explanation - In line 9 in the program above `c += a` where `c=21` and `c=a`. - The given expression is the same as `c = c + a`, which arithmetically is `c = 21 + 21`, hence the answer is `42`. - This same technique applies to every other expression assignment operator present in the code. - Taking a look at the table of operators with their descriptions and examples will make it easier to understand. Relevant Answers Explore Courses Free Resources License: [Creative Commons-Attribution-ShareAlike 4.0 (CC-BY-SA 4.0)](https://creativecommons.org/licenses/by-sa/4.0/)
Readable Markdown
``` #include <iostream>using namespace std;int main() {int a=21;int c;// using the simple assignment operatorc=a;cout << "Line 1: -= operator, value of c= "<<c<<endl;// using the add and assignment operatorc+=a;cout << "Line 2: += operator, value of c= "<<c<<endl;// using the subtract and assignment operatorc-=a;cout << "Line 3: -= operator, value of c= "<<c<<endl;// using the multiply and assignment operatorc*=a;cout << "Line 4: *= operator, value of c= "<<c<<endl;// using the divide and assignment operatorc/=a;cout << "Line 5: /= operator, value of c= "<<c<<endl;// lets give c another valuec=200;// using the modulo and assignment operatorc%=a;cout << "Line 6: %= operator, value of c= "<<c<<endl;// using the left shift and assignment operatorc<<=2;cout << "Line 7: <<= operator, value of c= "<<c<<endl;// using the right shift and assignment operatorc>>=2;cout << "Line 8: >>= operator, value of c= "<<c<<endl;// // using the bitwise and assignment operatorc&=2;cout << "Line 9: &= operator, value of c= "<<c<<endl;// using the bitwise exclusive or and assignment operatorc^=2;cout << "Line 10: ^= operator, value of c= "<<c<<endl;// using the bitwise inclusive or and assignment operatorc|=2;cout << "Line 11: |= operator, value of c=: "<<c<<endl;return 0;} ```
Shard28 (laksa)
Root Hash12990463358539855228
Unparsed URLio,educative!www,/answers/what-are-assignment-operators-in-cpp s443