

Assignment Operators in C
Operators are a fundamental part of all the computations that computers perform. Today we will learn about one of them known as Assignment Operators in C. Assignment Operators are used to assign values to variables. The most common assignment operator is = . Assignment Operators are Binary Operators.
- This article defines what are Assignment Operators in the C programming language.
- In this article, we will learn about all kinds of assignment operators in the C language using examples.
Introduction
Assignment Operators help us to assign the value or result of an expression to a variable and the value on the right side must be of the same data type as the variable on the left side. They have the lowest precedence level among all the operators, and it associates from right to left. The most commonly used Assignment Operator is = . Also, Assignment Operators fall under the category of Binary Operators.
For example, x = 4 ; then that means value 4 is assigned to variable x or we can say that variable x holds value 4 .
Explanation
Let me explain to you more about Assignment Operators. Don't worry after this section, you will fully understand the definition of Assignment Operators in C.
Our example is x = 4 , so what does it tell us?
- It simply says, " hey variable x please hold a value 4 which I give you as I wrote in the definition."
So can we say that always variables are on the Left Hand Side of the assignment operator and values are always on the Right Hand Side of the operator? YES . Please take a look at the image it will help you to understand more about the above wording.

The above diagram helps us to understand that the RHS value is assigned to the LHS variable.
The LHS and RHS are known as Operands.
So the operand on the LHS of the assignment operator must be a variable and operand on RHS must be a constant , variable or expression . For example:
As mentioned, precedence levels of assignment operators are lower than all the operators we have discussed so far and it associates from right to left. Now you may wonder what do you mean by it associates from right to left? Let's understand this together.
For example:
This is totally correct and means we can also assign the same value to multiple variables with one single line of code .
So what do you get from the above line of code? Simply, variable_x , variable_y and variable_z hold the same value. YES!! TRUE. But how?
The main question is here how value is assigned to them? is first variable_x get 10 or variable_y or variable_z ? What do you say? This answer is given by the line: It associates from right to left .
So that means we have to read the line from the right side to the left. Like, at first 10 is given to variable_z then variable_y gets the value present in the variable_z and after that variable_x get the value present in the variable_y . So the above wording is equivalent to the following expression.
This is the simplest explanation about assignment operator associativity.
The most basic Assignment operator is = . It requires two operands for its work. For example, = x doesn't make any sense but variable = x makes sense because it clearly says the variable variable stores the value of x . Therefore, Assignment operators are Binary operators.
Hopefully, every point in the definition is now clear to all of you.
List of All Assignment Operators in C
We have 2 types of Assignment Operators in C :
- Simple Assignment operator (Example : = ) .
- Compound Assignment Operators (Example : += , -= , &= ) .
Simple Assignment Operator in C
It is the operator used to assign the Right Operand to Left Operand . There is only one simple Assignment Operator and that is = . The general Syntax is like Left Operand = Right Operand .
Compound Assignment Operators in C
Any Binary Operator with a simple Assignment Operator will form Compound Assignment Operators.
The general syntax is like Left operand operation = Right operand . Here, the operation is what you want + , - , *, etc.
Let's take an example:
Here read carefully. After which, you will never forget how to read the syntax of a compound assignment operator.
So we read like this FIRST ADD 10 to variable_x , THEN WHATEVER THE RESULT, ASSIGN THAT RESULT TO variable_x . That means the above line of code is equal to
List of Assignment operators in C
This is the complete list of all assignment operators in C. To read the meaning of operator please keep in mind the above example.
Example program for Assignment Operators in C
This is a simple Assignment Operator.
+= Operator
This is the Addition Assignment Operator . In which the left operand becomes equal to the addition of the right operand and left operand.
In this program, x+=y means x+y , so we assign the result of x+y to x .
-= Operator
This is the Subtraction Assignment Operator .
In which left operand becomes equal to the subtraction of right operator from left operand.
The program performs the subtraction of two numbers i.e. x-=y means x = x-y . So the output is :
*= Operator
The main purpose of this operator is that this left operand becomes equal to the product of the left and right operand. This is the Multiplication Assignment Operator .
The program performs the multiplication of two numbers and then the result of the multiplication is assigned to the variable x .
/= Operator
This one is Division Assignment Operator . In this, the left operand becomes equal to the division of the left and right operand.
This program performs a division of two numbers and the result is assigned to x variable i.e. x/=y is the same as x = x/y .
%= Operator
It is well known Modulus Assignment Operator . In this , left operand becomes equal to the modulo of left and right operand.
In this program, the user checks the remainder of two number and assign that remainder to x variable.
<<= Operator
This is called the Left Shift Assignment Operator . For example x <<= y so in this, x becomes equal to x left shifted by y .
The program basically shifts every bit of x to the left side by y places and then assigns the result to x .
>>= Operator
This is called the Right Shift Assignment Operator . For example x >>= y so , x becomes equal to x right shifted by y .
The program has defined the result of expression when x is right-shifted by y places and the result is going to store in x variable.
&= Operator
This operator is called the Bitwise AND Assignment Operator . Left operand becomes equal to the bitwise AND of left and right operand.
The program performs Bitwise AND operation on every bit of x and y . After that result is going to be stored in variable x .
|= Operator
This is called the Bitwise Inclusive OR Assignment Operator Left operand becomes equal to bitwise OR of left and right operand.
like Bitwise AND Assignment Operator , this program also performs Bitwise OR operation on every bit of x and y . And after that result is going to store in x .
^= Operator
This is called the Bitwise Exclusive OR Assignment Operator Left operand becomes equal to bitwise XOR of left and right operand.
This will perform Bitwise XOR operation on every bit of x and y . After that result is going to store in x .
This is the detailed explanation with programs of all the assignment operators in C that we have. Hopefully, This is clear to you.
Happy Coding folks!!!
- Assignment operators are used to assign the result of an expression to a variable.
- There are two types of assignment operators in C. Simple assignment operator and compound assignment operator.
- Compound Assignment operators are easy to use and the left operand of expression needs not to write again and again.
- They work the same way in C++ as in C.

C – Assignment Operators
prev next, assignment operators in c:.
In C programs, values for the variables are assigned using assignment operators.
- For example, if the value “10” is to be assigned for the variable “sum”, it can be assigned as “sum = 10;”
- There are 2 categories of assignment operators in C language. They are, 1. Simple assignment operator ( Example: = ) 2. Compound assignment operators ( Example: +=, -=, *=, /=, %=, &=, ^= )
Example program for C assignment operators:
- In this program, values from 0 – 9 are summed up and total “45” is displayed as output.
- Assignment operators such as “=” and “+=” are used in this program to assign the values and to sum up the values.
Continue on types of C operators:
Click on each operator name below for detailed description and example programs.
Prev Next

- Design Pattern
- Interview Q
C Control Statements
C functions, c dynamic memory, c structure union, c file handling, c preprocessor, c command line, c programming test, c interview.
- Send your Feedback to [email protected]
Help Others, Please Share

Learn Latest Tutorials

Transact-SQL

Reinforcement Learning

R Programming

React Native

Python Design Patterns

Python Pillow

Python Turtle

Preparation

Verbal Ability

Interview Questions

Company Questions
Trending Technologies

Artificial Intelligence

Cloud Computing

Data Science

Machine Learning

B.Tech / MCA

Data Structures

Operating System

Computer Network

Compiler Design

Computer Organization

Discrete Mathematics

Ethical Hacking

Computer Graphics

Software Engineering

Web Technology

Cyber Security

C Programming

Control System

Data Mining

Data Warehouse
Javatpoint Services
JavaTpoint offers too many high quality services. Mail us on [email protected] , to get more information about given services.
- Website Designing
- Website Development
- Java Development
- PHP Development
- Graphic Designing
- Digital Marketing
- On Page and Off Page SEO
- Content Development
- Corporate Training
- Classroom and Online Training
Training For College Campus
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected] Duration: 1 week to 2 week

C++ Tutorial
C++ functions, c++ classes, c++ examples, c++ assignment operators, assignment operators.
Assignment operators are used to assign values to variables.
In the example below, we use the assignment operator ( = ) to assign the value 10 to a variable called x :
The addition assignment operator ( += ) adds a value to a variable:
A list of all assignment operators:

COLOR PICKER

Get your certification today!

Get certified by completing a course today!

Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
[email protected]
Your Suggestion:
Thank you for helping us.
Your message has been sent to W3Schools.
Top Tutorials
Top references, top examples, web certificates, get certified.
Learn C++ interactively.
Learn C++ practically and Get Certified .
Popular Tutorials
Popular examples, reference materials.
Learn C++ Interactively
Interactive C++ Course
C++ introduction.
- C++ Variables and Literals
- C++ Data Types
- C++ Basic I/O
- C++ Type Conversion
- C++ Operators
- C++ Comments
C++ Flow Control
- C++ if...else
- C++ for Loop
- C++ do...while Loop
- C++ continue
- C++ switch Statement
- C++ goto Statement
- C++ Functions
- C++ Function Types
- C++ Function Overloading
- C++ Default Argument
- C++ Storage Class
- C++ Recursion
- C++ Return Reference
C++ Arrays & String
- Multidimensional Arrays
- C++ Function and Array
- C++ Structures
- Structure and Function
- C++ Pointers to Structure
- C++ Enumeration
C++ Object & Class
- C++ Objects and Class
- C++ Constructors
- C++ Objects & Function
- C++ Operator Overloading
- C++ Pointers
- C++ Pointers and Arrays
- C++ Pointers and Functions
- C++ Memory Management
- C++ Inheritance
- Inheritance Access Control
- C++ Function Overriding
- Inheritance Types
- C++ Friend Function
- C++ Virtual Function
- C++ Templates
Related Topics
C++ Vectors
C++ Unordered Set
C++ STL Containers
- C++ Priority Queue
In this tutorial, we will learn about C++ STL List and its functions with the help of examples.
C++ List is a STL container that stores elements randomly in unrelated locations. To maintain sequential ordering, every list element includes two links:
- one that points to the previous element
- another that points to the next element

In C++, the STL list implements the doubly-linked list data structure . As a result, we can iterate both forward and backward.
- Create C++ STL List
To create a list, we need to include the list header file in our program.
Once we import the header file, we can now declare a list using the following syntax:
- std::list - declares a STL container of type list
- <Type> - the data type of the values to be stored in the list
- list_name - a unique name given to the list
- value1, value2, ... - values to be stored in the list
Let's see an example,
Note: We can also include list elements without mentioning the assignment operator. For example,
- Example: C++ STL List
In the above example, we have created a list named numbers with elements: 1 , 2 , 3 , 4 . We then used a ranged for loop to print the list elements.
Note: We have used list instead of std::list because we have already defined std namespace using using namespace std; .
- Basic operations on List
C++ STL provides various functions that we can use to perform different operations on lists. Let's look at some commonly used list functions to perform the following operations:
- Add elements
- Access elements
- Remove elements
1. Add Elements to a List in C++
We can add values in a list using the following functions:
- push_front() - inserts an element to the beginning of the list
- push_back() - adds an element to the end of the list
2. Access List Elements
We can access list elements using the following functions:
- front() - returns the first element of the list
- back() - returns the last element of the list
3. Delete List Elements
We can delete list elements using the following functions:
- pop_front() - removes the element at the beginning of the list
- pop_back() - removes the element at the end of the list
Here's an example,
- Other List Functions in C++
While there are many functions that can be used with lists, we will only look at some of the functions in the table below:
- Access elements using an iterator
We can use iterators to access a list element at a specified position. For example,
In the above example,
- list<int>::iterator - defines an iterator for a list of int type
- numbers.begin() - sets the iterator to point to the beginning of the list
Notice that we have used ++itr; repeatedly instead of adding an integer to itr like itr+3; .
This is because iterators are not simple numeric values like regular integers. They point to specific memory locations in the container. Incrementing an iterator with the ++ operator makes it point to the next element in the container.
To learn more about iterators, visit C++ STL Iterators .
Frequently Asked Questions
We use the insert() function to add an element at a specified position.
The syntax for insert() function for list is:
- iterator - points to the position where the value is to be inserted
- value - the actual value that needs to be inserted in the position specified by the iterator
We use remove() function to remove an element at a specified position.The syntax of remove() function is:
The remove() function can be used in the following two ways:
- Using Value
- Using Iterator
1. remove() using Value
2. remove() using iterator
Here, both elements with a value of 3 are deleted, even though we only used remove() function on the fourth element.
This is because the remove() function removes all the elements having the same value as the element pointed by the iterator.
Table of Contents
- Introduction
- Add Elements to a List in C++
- Access List Elements
- Delete List Elements
Sorry about that.
Related Tutorials
C++ Tutorial
Try PRO for FREE
- Data Structure & Algorithm Classes (Live)
- System Design (Live)
- DevOps(Live)
- Explore More Live Courses
- Interview Preparation Course
- Data Science (Live)
- GATE CS & IT 2024
- Data Structure & Algorithm-Self Paced(C++/JAVA)
- Data Structures & Algorithms in Python
- Explore More Self-Paced Courses
- C++ Programming - Beginner to Advanced
- Java Programming - Beginner to Advanced
- C Programming - Beginner to Advanced
- Android App Development with Kotlin(Live)
- Full Stack Development with React & Node JS(Live)
- Java Backend Development(Live)
- React JS (Basic to Advanced)
- JavaScript Foundation
- Complete Data Science Program(Live)
- Mastering Data Analytics
- CBSE Class 12 Computer Science
- School Guide
- All Courses
- Linked List
- Binary Tree
- Binary Search Tree
- Advanced Data Structure
- All Data Structures
- Asymptotic Analysis
- Worst, Average and Best Cases
- Asymptotic Notations
- Little o and little omega notations
- Lower and Upper Bound Theory
- Analysis of Loops
- Solving Recurrences
- Amortized Analysis
- What does 'Space Complexity' mean ?
- Pseudo-polynomial Algorithms
- Polynomial Time Approximation Scheme
- A Time Complexity Question
- Searching Algorithms
- Sorting Algorithms
- Graph Algorithms
- Pattern Searching
- Geometric Algorithms
- Mathematical
- Bitwise Algorithms
- Randomized Algorithms
- Greedy Algorithms
- Dynamic Programming
- Divide and Conquer
- Backtracking
- Branch and Bound
- All Algorithms
- Company Preparation
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Design Patterns
- System Design Tutorial
- Multiple Choice Quizzes
- Go Language
- Tailwind CSS
- Foundation CSS
- Materialize CSS
- Semantic UI
- Angular PrimeNG
- Angular ngx Bootstrap
- jQuery Mobile
- jQuery EasyUI
- React Bootstrap
- React Rebass
- React Desktop
- React Suite
- ReactJS Evergreen
- ReactJS Reactstrap
- BlueprintJS
- TensorFlow.js
- English Grammar
- School Programming
- Number System
- Trigonometry
- Probability
- Mensuration
- Class 8 Syllabus
- Class 9 Syllabus
- Class 10 Syllabus
- Class 8 Notes
- Class 9 Notes
- Class 10 Notes
- Class 11 Notes
- Class 12 Notes
- Class 8 Maths Solution
- Class 9 Maths Solution
- Class 10 Maths Solution
- Class 11 Maths Solution
- Class 12 Maths Solution
- Class 7 Notes
- History Class 7
- History Class 8
- History Class 9
- Geo. Class 7
- Geo. Class 8
- Geo. Class 9
- Civics Class 7
- Civics Class 8
- Business Studies (Class 11th)
- Microeconomics (Class 11th)
- Statistics for Economics (Class 11th)
- Business Studies (Class 12th)
- Accountancy (Class 12th)
- Macroeconomics (Class 12th)
- Machine Learning
- Data Science
- Mathematics
- Operating System
- Computer Networks
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- GATE 2024 Live Course
- GATE Computer Science Notes
- Last Minute Notes
- GATE CS Solved Papers
- GATE CS Original Papers and Official Keys
- GATE CS 2023 Syllabus
- Important Topics for GATE CS
- GATE 2023 Important Dates
- Software Design Patterns
- HTML Cheat Sheet
- CSS Cheat Sheet
- Bootstrap Cheat Sheet
- JS Cheat Sheet
- jQuery Cheat Sheet
- Angular Cheat Sheet
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- Wipro Coding Sheet
- Infosys Coding Sheet
- TCS Coding Sheet
- Cognizant Coding Sheet
- HCL Coding Sheet
- FAANG Coding Sheet
- Love Babbar Sheet
- Mass Recruiter Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Array Sheet
- String Sheet
- Graph Sheet
- ISRO CS Original Papers and Official Keys
- ISRO CS Solved Papers
- ISRO CS Syllabus for Scientist/Engineer Exam
- UGC NET CS Notes Paper II
- UGC NET CS Notes Paper III
- UGC NET CS Solved Papers
- Campus Ambassador Program
- School Ambassador Program
- Geek of the Month
- Campus Geek of the Month
- Placement Course
- Testimonials
- Student Chapter
- Geek on the Top
- Geography Notes
- History Notes
- Science & Tech. Notes
- Ethics Notes
- Polity Notes
- Economics Notes
- UPSC Previous Year Papers
- SSC CGL Syllabus
- General Studies
- Subjectwise Practice Papers
- Previous Year Papers
- SBI Clerk Syllabus
- General Awareness
- Quantitative Aptitude
- Reasoning Ability
- SBI Clerk Practice Papers
- SBI PO Syllabus
- SBI PO Practice Papers
- IBPS PO 2022 Syllabus
- English Notes
- Reasoning Notes
- Mock Question Papers
- IBPS Clerk Syllabus
- Apply for a Job
- Apply through Jobathon
- Hire through Jobathon
- All DSA Problems
- Problem of the Day
- GFG SDE Sheet
- Top 50 Array Problems
- Top 50 String Problems
- Top 50 Tree Problems
- Top 50 Graph Problems
- Top 50 DP Problems
- Solving For India-Hackthon
- GFG Weekly Coding Contest
- Job-A-Thon: Hiring Challenge
- BiWizard School Contest
- All Contests and Events
- Saved Videos
- What's New ?
- Data Structures
- Interview Preparation
- Topic-wise Practice
- Latest Blogs
- Write & Earn
- Web Development
Related Articles
- Write Articles
- Pick Topics to write
- Guidelines to Write
- Get Technical Writing Internship
- Write an Interview Experience
- Vector in C++ STL
- Arrays in C/C++
- Initialize a vector in C++ (7 different ways)
- Map in C++ Standard Template Library (STL)
- std::sort() in C++ STL
- Bitwise Operators in C/C++
- The C++ Standard Template Library (STL)
- Inheritance in C++
- Object Oriented Programming in C++
- C++ Classes and Objects
- Multidimensional Arrays in C / C++
- Virtual Function in C++
- Set in C++ Standard Template Library (STL)
- Constructors in C++
- vector erase() and clear() in C++
- C++ Data Types
- Left Shift and Right Shift Operators in C/C++
- Substring in C++
- Converting Strings to Numbers in C/C++
- unordered_map in C++ STL
- Templates in C++ with Examples
- Socket Programming in C/C++
- Operator Overloading in C++
- Copy Constructor in C++
- rand() and srand() in C++
- 2D Vector In C++ With User Defined Size
- Stack in C++ STL
- getline (string) in C++
- Priority Queue in C++ Standard Template Library (STL)
- Sorting a vector in C++
C++ Assignment Operator Overloading
- Difficulty Level : Medium
- Last Updated : 27 Oct, 2022
Prerequisite: Operator Overloading
The assignment operator,”=”, is the operator used for Assignment. It copies the right value into the left value. Assignment Operators are predefined to operate only on built-in Data types.
- Assignment operator overloading is binary operator overloading.
- Overloading assignment operator in C++ copies all values of one object to another object.
- Only a non-static member function should be used to overload the assignment operator.
We can’t directly use the Assignment Operator on objects. The simple explanation for this is that the Assignment Operator is predefined to operate only on built-in Data types. As the class and objects are user-defined data types, so the compiler generates an error.
here, a and b are of type integer, which is a built-in data type. Assignment Operator can be used directly on built-in data types.
c1 and c2 are variables of type “class C”. Here compiler will generate an error as we are trying to use an Assignment Operator on user-defined data types.
The above example can be done by implementing methods or functions inside the class, but we choose operator overloading instead. The reason for this is, operator overloading gives the functionality to use the operator directly which makes code easy to understand, and even code size decreases because of it. Also, operator overloading does not affect the normal working of the operator but provides extra functionality to it.
Now, if the user wants to use the assignment operator “=” to assign the value of the class variable to another class variable then the user has to redefine the meaning of the assignment operator “=”. Redefining the meaning of operators really does not change their original meaning, instead, they have been given additional meaning along with their existing ones.

Please Login to comment...
- cpp-operator
- cpp-operator-overloading
Improve your Coding Skills with Practice
Start your coding journey now.
The Simple Assignment Operator
- The equals sign, =, is known as the assignment operator in C
- The purpose of the assignment operator is to take the value from the right hand side of the operator ( the RHS value ), and store it in the variable on the left hand side ( the LHS ).
- X = Y + 7; - Valid: The sum of Y plus 7 will be stored in the variable X.
- X - Y = 7; - Invalid: Although this looks like a simple rearrangement of the above, the LHS is no longer a valid storage location.
- 7 = X - Y; - Invalid: The LHS is now a single entity, but it is a constant whose value cannot be changed.
- X = X + 7; - Valid: First the original value of X will be added to 7. Then this new total will be stored back into X, replacing the previous value.
Arithmetic Operators, +, -, *, /, %
- Ex: X = Y + 7;
- Ex: X = Y - 7;
- Ex: X = - Y;
- ( + can also be used as a unary operator, but there is no good reason to do so. )
- Ex: X = Y * 7;
- Ex: X = Y / 7;
- 9 / 10 yields zero, not 0.9 or 1.
- 17 / 5 yields 3.
- 9.0 / 10 yields 0.9, because there are two different types involved, and so the "smaller" int of 10 is promoted to a double precision 10.0 before the division takes place.
- int num = 9.0 / 10; stores 0. The division yields 0.9 as in the above example, but then it is truncated to the integer 0 by the assignment operator that stores the result in the int variable "num".
- Ex: K = N % 7;
- 17 % 5 yields 2.
- 3 % 5 yields 3.
- Mod only works with integers in C.
- If N % M is equal to zero, then it means N is evenly divisible by M. ( E.g. if N % 2 is 0, then N is even. )
- Therefore mod is often used to map a number into a given range.
- For example, rand( ) % 52 always yields a number in the range 0 to 51 inclusive, suitable for randomly selecting a card from a deck of 52 cards.
Precedence and Associativity
- Ex: what is the value of the expression 3 + 5 / 2 ?
- Assignment statements have the lowest precedence of all, so all other operations are performed before the result is assigned.
- Ex: In the expression 3 * ( 4 + 2 ), the addition is performed first, and then the multiplication.
- Ex: What is the value of the expression 5 / 3 * 2.0 ?
- A = B = C = 0;
- A full table of precedence and associativity is included in any good book on C Programming. There are also many versions of this information on the web.
Abbreviated Assignment Operators
- E.g. X = X + 7;
- Because this is so common, there are a number of operators that combine assignment with some other ( binary ) operator.
- Note that in these combined operators, that there is no space between the = and the other character, e.g. no space between the + and the = in +=.
- X *= 3 + 4;
- The above is equivalent to X = X * ( 3 + 4 );, not X = X * 3 + 4;
Auto Increment and Auto Decrement
- Another operation that is very common in programming is to either increase or decrease an integer by exactly 1, e.g. when counting up or counting down.
- N++; is equivalent to N += 1; which is equivalent to N = N + 1;
- N--; is equivalent to N -= 1; which is equivalent to N = N - 1;
- There are actually two versions of the auto increment/decrement operators, depending on whether the operator appears after the operand ( postfix, e.g. N++ ) or before the operand ( prefix, e.g. ++N ).
- For stand-alone statement that consist of nothing but the auto increment/decrement there is no difference between the two. Common convention is to use the postfix form, but prefix would work equivalently.
- If N is originally equal to 3, then the statement X = 2 * N++ * 3; will store 18 in X and then increment N to 4.
- If N is originally equal to 3, then the statement X = 2 * ++N * 3; will increment N to 4 first, and then store 24 in X.
- DANGER: If a variable is affected by an auto increment / decrement operator, never use that same variable more than once in the same statement. For example, the result of X = N++ * 3 + N; is undefined, because it is undetermined what value will be used for the second instance of N.
- ( Compare N++ +J to N+ ++J )

Assignment Operators in C

Introduction to Assignment Operators in C
Assignment operators are used for assigning value to the variable. Like any other operator, C also supports Assignment Operator which is a binary operator that operates on any two operands. It has 2 values such as the right value and the left value. It has lower precedence than all available operators but has higher precedence than the comma operator.

Different List of Assignment Operators in C
Below is the list of Assignment operators in C
Start Your Free Software Development Course
Web development, programming languages, Software testing & others
- The simple assignment operator (=) : This operator Assigns values from the right operands to the left operand.
- Add AND operator (+=): This operator adds the right operand to the left operand and assigns the output to the left operand.
- Subtract AND operator (-=): This operator subtracts the right operand from the left operand and assigns the result to the left operand.
- Multiply AND operator (*=): This operator multiplies the right operand with the left operand and assigns the result to the left operand.
- Divide AND operator (/=): This operator divides the left operand with the right operand and assigns the result to the left operand.
- Modulus AND operator (%=): This operator takes modulus using two operands and assigns the result to the left operand.
There are many other assignment operators such as Left shift AND (<<=) operator, Right shift AND operator (>>=), Bitwise AND assignment operator (&= ), Bitwise exclusive OR and assignment operator (^=), Bitwise inclusive OR and assignment operator(|=)
Examples of Assignment Operators in C
Examples of Assignment Operators are given below:
Program to implement the use of = operator:

Program to implement the use of Add AND operator (+=) in C:

Program to use Subtract AND operator (- =) in C:

Program to use Multiply AND operator (*=) in C:

Program to use Divide AND operator (/=) in C:

Program to use Modulus AND operator (%=) in C

Program to use Left shift AND (<<=) operator in C

Program to use Right shift AND (>>=) operator in C

Program to use Bitwise AND assignment operator (&= ) in C

Example #10
Program to use Bitwise exclusive OR and assignment operator (^=)

Example #11
Program to use Bitwise inclusive OR and assignment operator (|=) in C

Recommended Articles
This is a guide to Assignment Operators in C. Here we discuss different list of Assignment Operators in C along with the examples. You can also go through our other suggested articles to learn more –
- Logical Operators in C
- Logical Operators in C#
- Arithmetic Operators in Java
- JavaScript Assignment Operators

Related Courses

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept
By signing up, you agree to our Terms of Use and Privacy Policy .
Forgot Password?
This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Explore 1000+ varieties of Mock tests View more
Submit Next Question

- BYJU'S GATE
- GATE Study Material
- GATE Notes For CSE
- Introduction To C Programming
- Operators In C
Assignment Operators in C

We use this type of operator to transform as well as assign the values to any variable in an operation. In any given assignment operator, the right side is a value, and the left side is a variable. The value present on the right side of the operator must have the same data type as that of the variable present on the left side. In any other case, the compiler raises an error.
In this article, we will take a look into the Assignment Operators in C according to the GATE Syllabus for CSE (Computer Science Engineering) . Read ahead to know more.
Table of Contents
- Working Of Assignment Operators In C
- Example Of Assignment Operators In C
- Practice Problems On Assignment Operators In C
Types of Assignment Operators in C
An assignment operator is basically a binary operator that helps in modifying the variable to its left with the use of the value to its right. We utilize the assignment operators to transform and assign values to any variables.
Here is a list of the assignment operators that you can find in the C language:
- basic assignment ( = )
- subtraction assignment ( -= )
- addition assignment ( += )
- division assignment ( /= )
- multiplication assignment ( *= )
- modulo assignment ( %= )
- bitwise XOR assignment ( ^= )
- bitwise OR assignment ( |= )
- bitwise AND assignment ( &= )
- bitwise right shift assignment ( >>= )
- bitwise left shift assignment ( <<= )
Working of Assignment Operators in C
Here is a table that discusses, in brief, all the Assignment operators that the C language supports:
Example of Assignment Operators in C
Let us look at an example to understand how these work in a code:
#include <stdio.h>
int x = 21;
printf(“Line A – = Example of the Value of y = %d\n”, y );
printf(“Line B – -= Example of the Value of y = %d\n”, y );
printf(“Line C – += Example of the Value of c = %d\n”, c );
printf(“Line D – /= Example of the Value of y = %d\n”, y );
printf(“Line E – *= Example of the Value of y = %d\n”, y );
y <<= 2;
printf(“Line F – <<= Example of the Value of y = %d\n”, y );
printf(“Line G – %= Example of the Value of y = %d\n”, y );
y &= 2;
printf(“Line H – &= Example of the Value of y = %d\n”, y );
y >>= 2;
printf(“Line I – >>= Example of the Value of y = %d\n”, y );
printf(“Line J – |= Example of the Value of y = %d\n”, y );
printf(“Line K – ^= Example of the Value of y = %d\n”, y );
The compilation and execution of the program mentioned above will produce a result as follows:
Line A – = Example of the Value of y = 21
Line B – -= Example of the Value of y = 21
Line C – += Example of the Value of y = 42
Line D – /= Example of the Value of y = 21
Line E – *= Example of the Value of y = 441
Line F – <<= Example of the Value of y = 44
Line G – %= Example of the Value of y = 11
Line H – &= Example of the Value of y = 2
Line I – >>= Example of the Value of y = 11
Line J – |= Example of the Value of y = 2
Line K – ^= Example of the Value of y = 0
Here is another example of how the assignment operators work in the C language:
int y = 10;
printf(“z = x + y = %d \n”,z);
printf(“z += x = %d \n”,z);
printf(“z -= x = %d \n”,z);
printf(“z *= x = %d \n”,z);
printf(“z /= x = %d \n”,z);
printf(“z %= x = %d \n”,z);
c &= x ;
printf(“c &= x = %d \n”,z);
printf(“z ^= x = %d \n”,z);
printf(“z |= x = %d \n”,z);
z <<= 2 ;
printf(“z <<= 2 = %d \n”,z);
z >>= 2 ;
printf(“z >>= 2 = %d \n”,z);
The output generated here will be:
z = x + y = 15
z += x = 20
z -= x = 15
z *= x = 75
z &= x = 0
z ^= x = 10
z |= x = 10
z <<= 2 = 40
z >>= 2 = 10
z >>= 2 = 2
Practice Problems on Assignment Operators in C
1. What would be the output obtained from the program given below?
#include<stdio.h>
p += p += p += 3;
printf(“%d”,p);
Answer – A. 20
p+=p+=p+=3; it can written as p+=p+=p=p+3; p=2; Or, p+=p+=5; p=5; Or, p+=p=5+5; p=5; Or, p+=10; p=10; Or, p=p+10; p=10; Or, p=20. So, finally p=20.
2. Which of these is an invalid type of assignment operator?
D. None of these
Answer – D. None of these
All of these are valid types of assignment operators.
How does the /= operator work? Is it a combination of two other operators?
Yes, the /+ operator is a combination of the = and / operators. The / operator divides the current value of the available variable first on the left using the available value on the right. It then assigns the obtained result to the available variable on the left side.
What is the most basic operator among all the assignment operators available in the C language?
The = operator is the most basic one used in the C language. We use this operator to assign the value available in the right to the value mentioned on the left side of the operator.
Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria , GATE 2023 , GATE Admit Card , GATE Syllabus for CSE (Computer Science Engineering) , GATE CSE Notes , GATE CSE Question Paper , and more.
Also Explore,
- Arithmetic Operators in C
- Bitwise Operators in C
- Increment and Decrement Operators in C
- Logical Operators in C
- Operators in C
- Relational Operators in C
Leave a Comment Cancel reply
Your Mobile number and Email id will not be published. Required fields are marked *
Request OTP on Voice Call
Post Comment

Connect with us for GATE Preparation
Register now to get complete assistance for the gate 2022 exam.
- Share Share
Register with BYJU'S & Download Free PDFs
Conditional Operator in C ( ?: ) with Example
Please enable JavaScript
What is a Conditional Operator in C
Syntax of conditional operator in c, conditional operator example, more example of conditional operator in c, more than one conditional operator in a statement, conditional operator in c for three variables, choose a c conditional operator from the list, choose a syntax for c ternary operator from the list.
Q7) What is the other name for the conditional operator? The other name for the conditional operator is the ternary operator.
if(typeof ez_ad_units!='undefined'){ez_ad_units.push([[300,250],'knowprogram_com-leader-3','ezslot_17',117,'0','0'])};__ez_fad_position('div-gpt-ad-knowprogram_com-leader-3-0'); if(typeof ez_ad_units!='undefined'){ez_ad_units.push([[300,250],'knowprogram_com-leader-3','ezslot_18',117,'0','1'])};__ez_fad_position('div-gpt-ad-knowprogram_com-leader-3-0_1'); if(typeof ez_ad_units!='undefined'){ez_ad_units.push([[300,250],'knowprogram_com-leader-3','ezslot_19',117,'0','2'])};__ez_fad_position('div-gpt-ad-knowprogram_com-leader-3-0_2'); .leader-3-multi-117{border:none!important;display:block!important;float:none!important;line-height:0;margin-bottom:15px!important;margin-left:auto!important;margin-right:auto!important;margin-top:15px!important;max-width:100%!important;min-height:250px;min-width:300px;padding:0;text-align:center!important} Leave a Comment Cancel Reply

- Data Structure
- Coding problems
- Kotlin programs
- C Interview programs
- C++ Aptitude
- Java Aptitude
- C# Aptitude
- PHP Aptitude
- Linux Aptitude
- DBMS Aptitude
- Networking Aptitude
- AI Aptitude
- MIS Executive
- HR Interview Que.
- Web Technologie MCQs
- CS Subjects MCQs
- Databases MCQs
- Programming MCQs
- Testing Software MCQs
- Commerce MCQs
- More MCQs...
- CS fundamental
- Operating systems
- Computer networks
- Software Engineering
- Discrete Mathematics
- Digital Electronics
- Data Mining
- Embedded systems
- Cloud computing
- Cryptography
- Big Data & Hadoop
- Machine Learning
- More Tutorials...
- Tech Articles
- Code Examples
- Programmer's Calculator
- XML Sitemap Generator

Home » C Popular & Interesting Questions
What is the difference between = (Assignment) and == (Equal to) operators in C?
Difference between assignment (=) vs equal to (==) operators in c.
Many times this question arises what is the difference between = and == operators in C programming language? Here we are going to tell you exactly what the differences between these two operators are.
Assignment Operator (=)
= is an Assignment Operator in C, C++ and other programming languages, It is Binary Operator which operates on two operands.
= assigns the value of right side expression’s or variable’s value to the left side variable.
Let's understand by example:
Here, When first expression evaluates value of (a+b) will be assigned into x and in second expression y=x; value of variable x will be assigned into y .
Equal To Operator (==)
== is an Equal To Operator in C and C++ only, It is Binary Operator which operates on two operands.
== compares value of left and side expressions, return 1 if they are equal other will it will return 0.
When expression x==y evaluates, it will return 1 (it means condition is TRUE ) and "TRUE" will print.
So it's cleared now, , both are not same , = is an Assignment Operator it is used to assign the value of variable or expression, while == is an Equal to Operator and it is a relation operator used for comparison (to compare value of both left and right side operands).
Preparation
What's New (MCQs)
- C Language MCQs
- Python MCQs
- MongoDB MCQs
- Blockchain MCQs
- AutoCAD MCQs
- ASP.Net MCQs
- JavaScript MCQs
- jQuery MCQs
- ReactJS MCQs
- AngularJS MCQs
- Advanced CSS MCQs
- PL/SQL MCQs
- Oracle MCQs
- SQLite MCQs
- CouchDB MCQs
- MariaDB MCQs
- MS Word MCQs
- MS Excel MCQs
- MS PowerPoint MCQs
- Google Sheets MCQs
- Software Engineering MCQs
- Operating System MCQs
- Data Analytics and Visualization MCQs
- WordPress MCQs
- Blogging MCQs
- Digital Marketing MCQs
- Online Marketing MCQs
- Adobe After Effects MCQs
- Adobe Dreamweaver MCQs
- Adobe Illustrator MCQs
- CorelDRAW MCQs
- Google Chrome MCQs
- Bugzilla MCQs
- OpenStack MCQs
- JMeter MCQs
- ETL Testing MCQs
- Appium MCQs
- Control Systems MCQs
- PySpark MCQs
- Cucumber Testing MCQs
- UiPath MCQs
- TestNG MCQs
- Software Architecture MCQs
- Software Testing MCQs
- Selenium MCQs
- Agile Methodology MCQs
- AWS (Amazon Web Services) MCQs
- Microsoft Azure MCQs
- Energy & Environment Engineering MCQs
- Project Management MCQs
- Marketing MCQs
- Generally Accepted Accounting Principles MCQs
- Bills of Exchange MCQs
- Business Environment MCQs
- Sustainable Development MCQs
- Marginal Costing and Absorption Costing MCQs
- Globalisation MCQs
- Indian Economy MCQs
- Retained Earnings MCQs
- Depreciation MCQs
- Partnership MCQs
- Sole Proprietorship MCQs
- Goods and Services Tax (GST) MCQs
- Cooperative Society MCQs
- Capital Market MCQs
- Business Studies MCQs
- Basic Accounting MCQs
- MIS Executive Interview Questions
- Go Language Interview Questions
Top Interview Coding Problems/Challenges!
- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path
Comments and Discussions!
IncludeHelp's Blogs
- Do's and Don'ts For Dressing Up For Interviews
- Tips To Improve Spoken English
- 20 Smart Questions To Ask During An Interview
- Common Body Language Mistakes to Avoid During Interviews
- Is it important to have a college degree in today's world?
Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML Solved programs: » C » C++ » DS » Java » C# Aptitude que. & ans.: » C » C++ » Java » DBMS Interview que. & ans.: » C » Embedded C » Java » SEO » HR CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS More: » Articles » Puzzles » News/Updates
ABOUT SECTION » About us » Contact us » Feedback » Privacy policy
STUDENT'S SECTION » Internship » Certificates » Content Writers of the Month
SUBSCRIBE » Facebook » LinkedIn » Subscribe through email
© https://www.includehelp.com some rights reserved.
Learn coding interactively.
Popular tutorials, learn python interactively, popular examples, introduction.
- C# Hello World
- C# Keywords & Identifiers
- C# Variables
C# Operators
- C# Operator Precedence
- C# Bitwise Operators
- C# Basic I/O
- C# Expressions & Statements
- C# Comments
Flow Control
- C# if...else
- C# switch Statement
- C# Ternary Operator
- C# for Loop
- C# while Loop
- C# Nested Loops
- C# break Statement
- C# continue Statement
- C# Multidimensional Arrays
- C# Jagged Array
- C# foreach Loop
- C# Class and Objects
- C# Access Modifiers
- C# Variable Scope
- C# Constructors
- C# this Keyword
- C# static Keyword
- C# Inheritance
- C# Abstract Class & Methods
- C# Nested Class
- C# Partial Class
- C# Sealed Class
- C# Interface
- C# Method Overloading
- C# Constructor Overloading
Additional Topics
- C# Type Conversion
- C# Preprocessor Directives
- C# Namespaces
Related Topics
C# Bitwise and Bit Shift Operators
C# Operator Precedence and Associativity
C# ternary (? :) Operator
C# Basic Input and Output
- C# if, if...else, if...else if and Nested if Statement
- C# Exception Handling
In this article, we will learn everything about different types of operators in C# programming language and how to use them.
Operators are symbols that are used to perform operations on operands. Operands may be variables and/or constants.
For example , in 2+3 , + is an operator that is used to carry out addition operation, while 2 and 3 are operands.
Operators are used to manipulate variables and values in a program. C# supports a number of operators that are classified based on the type of operations they perform.
1. Basic Assignment Operator
Basic assignment operator (=) is used to assign values to variables. For example,
Here, 50.05 is assigned to x.
Example 1: Basic Assignment Operator
When we run the program, the output will be:
This is a simple example that demonstrates the use of assignment operator.
You might have noticed the use of curly brackets { } in the example. We will discuss about them in string formatting . For now, just keep in mind that {0} is replaced by the first variable that follows the string, {1} is replaced by the second variable and so on.
2. Arithmetic Operators
Arithmetic operators are used to perform arithmetic operations such as addition, subtraction, multiplication, division, etc.
For example,
Example 2: Arithmetic Operators
Arithmetic operations are carried out in the above example. Variables can be replaced by constants in the statements. For example,
3. Relational Operators
Relational operators are used to check the relationship between two operands. If the relationship is true the result will be true , otherwise it will result in false .
Relational operators are used in decision making and loops.
Example 3: Relational Operators
4. logical operators.
Logical operators are used to perform logical operation such as and , or . Logical operators operates on boolean expressions ( true and false ) and returns boolean values. Logical operators are used in decision making and loops.
Here is how the result is evaluated for logical AND and OR operators.
In simple words, the table can be summarized as:
- If one of the operand is true, the OR operator will evaluate it to true .
- If one of the operand is false, the AND operator will evaluate it to false .
Example 4: Logical Operators
5. unary operators.
Unlike other operators, the unary operators operates on a single operand.
Example 5: Unary Operators
The increment (++) and decrement (--) operators can be used as prefix and postfix. If used as prefix, the change in value of variable is seen on the same line and if used as postfix, the change in value of variable is seen on the next line. This will be clear by the example below.
Example 6: Post and Pre Increment operators in C#
We can see the effect of using ++ as prefix and postfix. When ++ is used after the operand, the value is first evaluated and then it is incremented by 1 . Hence the statement
prints 10 instead of 11 . After the value is printed, the value of number is incremented by 1 .
The process is opposite when ++ is used as prefix. The value is incremented before printing. Hence the statement
prints 12 .
The case is same for decrement operator (--) .
6. Ternary Operator
The ternary operator ? : operates on three operands. It is a shorthand for if-then-else statement. Ternary operator can be used as follows:
The ternary operator works as follows:
- If the expression stated by Condition is true , the result of Expression1 is assigned to variable.
- If it is false , the result of Expression2 is assigned to variable.
Example 7: Ternary Operator
To learn more, visit C# ternary operator .
7. Bitwise and Bit Shift Operators
Bitwise and bit shift operators are used to perform bit manipulation operations.
Example 8: Bitwise and Bit Shift Operator
To learn more, visit C# Bitwise and Bit Shift operator .
8. Compound Assignment Operators
Example 9: compound assignment operator.
We will discuss about Lambda operators in later tutorial.
Table of Contents
- Basic Assignment Operator
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Unary Operators
- Ternary Operator
- Bitwise and Bit Shift Operators
- Compound Assignment Operators
Sorry about that.
Related Tutorials
C# Tutorial

IMAGES
VIDEO
COMMENTS
Different types of assignment operators are shown below: "=": This is the simplest assignment operator. This operator is used to assign the value on the right to the variable on the left. For example: a = 10; b = 20; ch = 'y'; "+=": This operator is combination of '+' and '=' operators.
Line 1 - = Operator Example, Value of c = 21 Line 2 - += Operator Example, Value of c = 42 Line 3 - -= Operator Example, Value of c = 21 Line 4 - *= Operator Example, Value of c = 441 Line 5 - /= Operator Example, Value of c = 21 Line 6 - %= Operator Example, Value of c = 11 Line 7 - >= Operator Example, Value of c = 11 Line 9 - &= Operator …
The Assignment operators in C are some of the Programming operators that are useful for assigning the values to the declared variables. Equals (=) operator is the most commonly used assignment operator. For example: int i = 10; The below table displays all the assignment operators present in C Programming with an example.
We have 2 types of Assignment Operators in C : Simple Assignment operator (Example : = ). Compound Assignment Operators (Example : += , -= , &= ). Simple Assignment Operator in C It is the operator used to assign the Right Operand to Left Operand. There is only one simple Assignment Operator and that is = .
There are 2 categories of assignment operators in C language. They are, 1. Simple assignment operator ( Example: = ) 2. Compound assignment operators ( Example: +=, -=, *=, /=, %=, &=, ^= ) Example program for C assignment operators: In this program, values from 0 - 9 are summed up and total "45" is displayed as output.
Example 1: Arithmetic Operators // Working of arithmetic operators #include <stdio.h> int main() { int a = 9,b = 4, c; c = a+b; printf("a+b = %d \n",c); c = a-b; printf("a-b = %d \n",c); c = a*b; printf("a*b = %d \n",c); c = a/b; printf("a/b = %d \n",c); c = a%b; printf("Remainder when a divided by b = %d \n",c); return 0; } Run Code Output
For example, + and - are the operators to perform addition and subtraction in any C program. C has many operators that almost perform all types of operations. These operators are really useful and can be used to perform every operation. Additionally, you can also learn more about the uses of C language. Basics to Advanced - Learn It All!
The assignment operator is used to assign the value, variable and function to another variable. Let's discuss the various types of the assignment operators such as =, +=, -=, /=, *= and %=. Example of the Assignment Operators: A = 5; // use Assignment symbol to assign 5 to the operand A B = A; // Assign operand A to the B
Assignment operators are used to assign values to variables. In the example below, we use the assignment operator ( =) to assign the value 10 to a variable called x: Example int x = 10; Try it Yourself » The addition assignment operator ( +=) adds a value to a variable: Example int x = 10; x += 5; Try it Yourself »
C++ List is a STL container that stores elements randomly in unrelated locations. To maintain sequential ordering, every list element includes two links: one that points to the previous element; another that points to the next element; C++ STL list implementation. In C++, the STL list implements the doubly-linked list data structure. As a ...
The assignment operator,"=", is the operator used for Assignment. It copies the right value into the left value. Assignment Operators are predefined to operate only on built-in Data types. Assignment operator overloading is binary operator overloading. Overloading assignment operator in C++ copies all values of one object to another object.
👇Assignment Operators and Shorthand Operator in C Programming - In Hindi - Tutorial#5C-Program Playlist - https://youtube.com/playlist...
Introduction to C Programming Operators The Simple Assignment Operator. The equals sign, =, is known as the assignment operator in C; The purpose of the assignment operator is to take the value from the right hand side of the operator ( the RHS value ), and store it in the variable on the left hand side ( the LHS ). Note the following examples:
Assignment Operators There are following assignment operators supported by C language: Show Examples Operator Description Example = Simple assignment operator, Assigns values from right side operands to left side operand C = A + B will assign value of A + B into C += Add AND assignment operator, It adds right
Examples of Assignment Operators are given below: Example #1 Program to implement the use of = operator: Code: #include<stdio.h> #include<conio.h> int main() { int X, Y, total; printf("Enter the value of X: "); scanf("%d",& X); printf("Enter the value of Y: "); scanf("%d",& Y); total = X + Y; printf("%d", total); return 0; } Output: Example #2
In this C Programming Video Tutorial we will learn about assignment operators in detail.Operators are the symbol which will perform different operation on th...
Here is a list of the assignment operators that you can find in the C language: basic assignment ( = ) subtraction assignment ( -= ) addition assignment ( += ) division assignment ( /= ) multiplication assignment ( *= ) modulo assignment ( %= ) bitwise XOR assignment ( ^= ) bitwise OR assignment ( |= ) bitwise AND assignment ( &= )
The conditional operator in C is a conditional statement that returns the first value if the condition is true and returns another value if the condition is false. It is similar to the if-else statement. The if-else statement takes more than one line of the statements, but the conditional operator finishes the same task in a single statement.
Assignment Operator (=) = is an Assignment Operator in C, C++ and other programming languages, It is Binary Operator which operates on two operands. = assigns the value of right side expression's or variable's value to the left side variable. Let's understand by example: x = (a + b); y = x;
Example: a simple addition program. The following program adds two operands using AND, XOR and left shift (<<). ... Bitwise assignment operators. C provides a compound assignment operator for each binary arithmetic and bitwise operation. Each operator accepts a left operand and a right operand, performs the appropriate binary operation on both ...
Operators are used to manipulate variables and values in a program. C# supports a number of operators that are classified based on the type of operations they perform. 1. Basic Assignment Operator. Basic assignment operator (=) is used to assign values to variables. For example, double x; x = 50.05; Here, 50.05 is assigned to x.