CProgramming Tutorial

  • C Programming Tutorial
  • Basics of C
  • C - Overview
  • C - Features
  • C - History
  • C - Environment Setup
  • C - Program Structure
  • C - Hello World
  • C - Compilation Process
  • C - Comments
  • C - Keywords
  • C - Identifiers
  • C - User Input
  • C - Basic Syntax
  • C - Data Types
  • C - Variables
  • C - Integer Promotions
  • C - Type Conversion
  • C - Type Casting
  • C - Booleans
  • Constants and Literals in C
  • C - Constants
  • C - Literals
  • C - Escape sequences
  • C - Format Specifiers
  • Operators in C
  • C - Operators
  • C - Arithmetic Operators
  • C - Relational Operators
  • C - Logical Operators
  • C - Bitwise Operators
  • C - Assignment Operators
  • C - Unary Operators
  • C - Increment and Decrement Operators
  • C - Ternary Operator
  • C - sizeof Operator
  • C - Operator Precedence
  • C - Misc Operators
  • Decision Making in C
  • C - Decision Making
  • C - if statement
  • C - if...else statement
  • C - nested if statements
  • C - switch statement
  • C - nested switch statements
  • C - While loop
  • C - For loop
  • C - Do...while loop
  • C - Nested loop
  • C - Infinite loop
  • C - Break Statement
  • C - Continue Statement
  • C - goto Statement
  • Functions in C
  • C - Functions
  • C - Main Function
  • C - Function call by Value
  • C - Function call by reference
  • C - Nested Functions
  • C - Variadic Functions
  • C - User-Defined Functions
  • C - Callback Function
  • C - Return Statement
  • C - Recursion
  • Scope Rules in C
  • C - Scope Rules
  • C - Static Variables
  • C - Global Variables
  • Arrays in C
  • C - Properties of Array
  • C - Multi-Dimensional Arrays
  • C - Passing Arrays to Function
  • C - Return Array from Function
  • C - Variable Length Arrays
  • Pointers in C
  • C - Pointers
  • C - Pointers and Arrays
  • C - Applications of Pointers
  • C - Pointer Arithmetics
  • C - Array of Pointers
  • C - Pointer to Pointer
  • C - Passing Pointers to Functions
  • C - Return Pointer from Functions
  • C - Function Pointers
  • C - Pointer to an Array
  • C - Pointers to Structures
  • C - Chain of Pointers
  • C - Pointer vs Array
  • C - Character Pointers and Functions
  • C - NULL Pointer
  • C - void Pointer
  • C - Dangling Pointers
  • C - Dereference Pointer
  • C - Near, Far and Huge Pointers
  • C - Initialization of Pointer Arrays
  • C - Pointers vs. Multi-dimensional Arrays
  • Strings in C
  • C - Strings
  • C - Array of Strings
  • C - Special Characters
  • C Structures and Unions
  • C - Structures
  • C - Structures and Functions
  • C - Arrays of Structures
  • C - Self-Referential Structures
  • C - Lookup Tables
  • C - Dot (.) Operator
  • C - Enumeration (or enum)
  • C - Structure Padding and Packing
  • C - Nested Structures
  • C - Anonymous Structure and Union
  • C - Bit Fields
  • C - Typedef
  • File Handling in C
  • C - Input & Output
  • C - File I/O (File Handling)
  • C Preprocessors
  • C - Preprocessors
  • C - Pragmas
  • C - Preprocessor Operators
  • C - Header Files
  • Memory Management in C
  • C - Memory Management
  • C - Memory Address
  • C - Storage Classes
  • Miscellaneous Topics
  • C - Error Handling
  • C - Variable Arguments
  • C - Command Execution
  • C - Math Functions
  • C - Static Keyword
  • C - Random Number Generation
  • C - Command Line Arguments
  • C Programming Resources
  • C - Questions & Answers
  • C - Quick Guide
  • C - Cheat Sheet
  • C - Useful Resources
  • C - Discussion
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary

Assignment Operators in C

In C language, the assignment operator stores a certain value in an already declared variable. A variable in C can be assigned the value in the form of a literal, another variable, or an expression.

The value to be assigned forms the right-hand operand, whereas the variable to be assigned should be the operand to the left of the " = " symbol, which is defined as a simple assignment operator in C.

In addition, C has several augmented assignment operators.

The following table lists the assignment operators supported by the C language −

Operator Description Example
= Simple assignment operator. Assigns values from right side operands to left side operand C = A + B will assign the value of A + B to C
+= Add AND assignment operator. It adds the right operand to the left operand and assign 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
/= Divide 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 >>= 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 |= 2 is same as C = C | 2

Simple Assignment Operator (=)

The = operator is one of the most frequently used operators in C. As per the ANSI C standard, all the variables must be declared in the beginning. Variable declaration after the first processing statement is not allowed.

You can declare a variable to be assigned a value later in the code, or you can initialize it at the time of declaration.

You can use a literal, another variable, or an expression in the assignment statement.

Once a variable of a certain type is declared, it cannot be assigned a value of any other type. In such a case the C compiler reports a type mismatch error.

In C, the expressions that refer to a memory location are called "lvalue" expressions. A lvalue may appear as either the left-hand or right-hand side of an assignment.

On the other hand, the term rvalue refers to a data value that is stored at some address in memory. A rvalue is an expression that cannot have a value assigned to it which means an rvalue may appear on the right-hand side but not on the left-hand side of an assignment.

Variables are lvalues and so they may appear on the left-hand side of an assignment. Numeric literals are rvalues and so they may not be assigned and cannot appear on the left-hand side. Take a look at the following valid and invalid statements −

Augmented Assignment Operators

In addition to the = operator, C allows you to combine arithmetic and bitwise operators with the = symbol to form augmented or compound assignment operator. The augmented operators offer a convenient shortcut for combining arithmetic or bitwise operation with assignment.

For example, the expression "a += b" has the same effect of performing "a + b" first and then assigning the result back to the variable "a".

Run the code and check its output −

Similarly, the expression "a <<= b" has the same effect of performing "a << b" first and then assigning the result back to the variable "a".

Here is a C program that demonstrates the use of assignment operators in C −

When you compile and execute the above program, it will produce the following result −

01 Career Opportunities

02 beginner, 03 intermediate, 04 advanced, 05 training programs, c programming assignment operators, free c programming online course with certificate, what is an assignment operator in c, types of assignment operators in c.

1. Simple Assignment Operator (=)

Example of simple assignment operator.

2. Compound Assignment Operators

+=addition assignmentIt adds the right operand to the left operand and assigns the result to the left operand.
-=subtraction assignmentIt subtracts the right operand from the left operand and assigns the result to the left operand.
*=multiplication assignmentIt multiplies the right operand with the left operand and assigns the result to the left operand
/=division assignmentIt divides the left operand with the right operand and assigns the result to the left operand.
%=modulo assignmentIt takes modulus using two operands and assigns the result to the left operand.

Example of Augmented Arithmetic and Assignment Operators

&=bitwise AND assignmentIt performs the bitwise AND operation on the variable with the value on the right
|=bitwise OR assignmentIt performs the bitwise OR operation on the variable with the value on the right
^=bitwise XOR assignmentIt performs the bitwise XOR operation on the variable with the value on the right
<<=bitwise left shift assignmentShifts the bits of the variable to the left by the value on the right
>>=bitwise right shift assignmentShifts the bits of the variable to the right by the value on the right

Example of Augmented Bitwise and Assignment Operators

Practice problems on assignment operators in c, 1. what will the value of "x" be after the execution of the following code, 2. after executing the following code, what is the value of the number variable, benefits of using assignment operators, best practices and tips for using the assignment operator, live classes schedule.

Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast
Filling Fast

About Author

Next: if Statement , Up: Statements   [ Contents ][ Index ]

19.1 Expression Statement

The most common kind of statement in C is an expression statement . It consists of an expression followed by a semicolon. The expression’s value is discarded, so the expressions that are useful are those that have side effects: assignment expressions, increment and decrement expressions, and function calls. Here are examples of expression statements:

In very unusual circumstances we use an expression statement whose purpose is to get a fault if an address is invalid:

If the target of p is not declared volatile , the compiler might optimize away the memory access, since it knows that the value isn’t really used. See volatile .

home

  • What is C Language
  • History of C
  • Features of C
  • How to install C
  • First C Program
  • Compilation Process in C
  • printf scanf
  • Variables in C
  • Data Types in c
  • Keywords in c
  • C Identifiers
  • C Operators
  • C Format Specifier
  • C Escape Sequence
  • ASCII value in C
  • Constants in C
  • Literals in C
  • Tokens in C
  • Static in C
  • Programming Errors in C
  • Compile time vs Runtime
  • Conditional Operator in C
  • Bitwise Operator in C
  • 2s complement in C

C Fundamental Test

C control statements.

  • if-else vs switch
  • C do-while loop
  • C while loop
  • Nested Loops in C
  • Infinite Loop in C
  • Type Casting
  • C Control Statement Test

C Functions

  • What is function
  • Call: Value & Reference
  • Recursion in c
  • Storage Classes
  • C Functions Test
  • Return an Array in C
  • Array to Function

C Array Test

  • C Pointer to Pointer
  • C Pointer Arithmetic
  • Dangling Pointers in C
  • sizeof() operator in C
  • const Pointer in C
  • void pointer in C
  • C Dereference Pointer
  • Null Pointer in C
  • C Function Pointer
  • Function pointer as argument in C

C Pointers Test

C dynamic memory.

  • Dynamic memory
  • String in C
  • C gets() & puts()
  • C String Functions

C String Test

  • C Math Functions

C Structure Union

  • C Structure
  • typedef in C
  • C Array of Structures
  • C Nested Structure
  • Structure Padding in C

C Structure Test

  • C File Handling
  • C fprintf() fscanf()
  • C fputc() fgetc()
  • C fputs() fgets()
  • C Preprocessor

C Preprocessor Test

C command line.

  • Command Line Arguments
  • C Expressions
  • Data Segments
  • Flow of C Program
  • Classification of Programming Languages
  • What is getch() in C
  • What is the function call in C
  • typedef vs define in C
  • C Programming Test
  • Top 10+ C Programs
  • Fibonacci Series
  • Prime Number
  • Palindrome Number
  • C program to compare the two strings
  • Strings Concatenation in C
  • Armstrong Number
  • Sum of digits
  • Count the number of digits in C
  • Reverse Number
  • Swap Number
  • Print "Hello" without ;
  • Assembly code in C
  • C program without main
  • Matrix Multiplication
  • Decimal to Binary
  • Number in Characters
  • Alphabet Triangle
  • Number Triangle
  • Fibonacci Triangle
  • Hexadecimal to Binary
  • Hexadecimal to Decimal
  • Octal to Hexadecimal in C
  • Strong number in C
  • Star Program in C
  • itoa Function in C
  • Extra Long Factorials in C
  • Leap year program in C
  • Perfect Number Program in C
  • Variables vs Constants
  • Round Robin Program in C with Output
  • C Program to find the roots of quadratic equation
  • Type Casting vs Type Conversion
  • How to run a C program in Visual Studio Code
  • Modulus Operator in C/C++
  • Sum of first N natural numbers in C
  • Big O Notation in C
  • LCM of two numbers in C
  • while loop vs do-while loop in C
  • Memory Layout in C
  • Balanced Parenthesis in C
  • Binary to Decimal Number in C
  • GCD of two numbers in C
  • Getchar() function in C
  • flowchart in C
  • Simpson Method
  • Pyramid Patterns in C
  • Random Function in C
  • Floyd's Triangle in C
  • C Header Files
  • abs() function in C
  • Atoi() function in C
  • Structure Pointer in C
  • sprintf() in C
  • Range of Int in C
  • C Program to convert 24 Hour time to 12 Hour time
  • What is double in C
  • What is the main in C
  • Calculator Program in C
  • Calloc in C
  • user-defined vs library function in C
  • ASCII Table in C
  • Static function in C
  • Reverse a String in C
  • Twin Prime Numbers in C
  • strchr() function in C
  • Structure of a C program
  • Power Function in C
  • Malloc in C
  • Table Program in C
  • Types of Recursion in C
  • Convert Uppercase to Lowercase in C
  • Unary Operator in C
  • Arithmetic Operator in C
  • Ceil Function in C
  • Relational Operator in C
  • Assignment Operator in C
  • Pre-increment and Post-increment Operator in C
  • Pointer vs array in C
  • Restrict keyword in C
  • The exit() function in C
  • Const Qualifier in C
  • Sequence Points in C
  • Anagram in C
  • Increment and Decrement Operators in C
  • Logical AND Operator in C
  • Shift Operators in C
  • Near, Far, and Huge pointers in C language
  • Magic Number in C
  • Remove Duplicate Elements from an Array in C
  • Generic Linked list in C
  • isalnum() function in C
  • isalpha() function in C
  • Bisection Method in C
  • snprintf() function in C
  • Remove an element from an array in C
  • Square Root in C
  • isprint() function in C
  • isdigit() function in C
  • isgraph() function in C
  • Logical NOT (!) Operator in C
  • Self-referential structure
  • Break Vs. Continue in C
  • For vs. While loop in C
  • Abort() Function in C
  • Assert in C
  • Floor() Function in C
  • memcmp() in C
  • Find Day from Day in C without Using Function
  • Find Median of 1D Array Using Functions in C
  • Find Reverse of an Array in C Using Functions
  • Find Occurrence of Substring in C using Function
  • Find out Power without Using POW Function in C
  • Exponential() in C
  • islower() in C
  • memcpy() in C
  • memmove() in C
  • Matrix Calculator in C
  • Bank Account Management System
  • Library Management System in C
  • 8th Sep - Calendar Application in C
  • 8th Sep - va_start() in C programming
  • 8th Sep - Ascii vs Unicode
  • Student Record System in C
  • Contact Management System in C
  • Cricket Score Sheet in C
  • C/C++ Tricky Programs
  • Clearing the Input Buffer in C/C++
  • In-place Conversion of Sorted DLL to Balanced BST
  • Merge Two Balanced Binary Search Trees
  • Responsive Images in Bootstrap with Examples
  • Why can't a Priority Queue Wrap around like an Ordinary Queue
  • Customer Billing System in C
  • Builtin functions of GCC compiler
  • Integer Promotions in C
  • Bit Fields in C
  • Department Management System in C
  • Local Labels in C
  • School Billing System in C
  • Banking Account System in C using File handling
  • Data Structures and Algorithms in C - Set 1
  • Data Structures and Algorithms in C - Set 2
  • Employee Record System in C
  • Hangman Game in C
  • Hospital Management System in C
  • Number of even and odd numbers in a given range
  • qsort() in C
  • Quiz game in C
  • An Array of Strings in C
  • Peak element in the Array in C
  • Move all negative elements to one side of an Array-C
  • Reverse an Array in C
  • 3 way merge sort in c
  • Segregate 0s and 1s in an array
  • Articulation Points and Bridges
  • Execution of printf with ++ Operators
  • Understanding the extern Keyword in C
  • Banker's Algorithm in C
  • FIFO Page Replacement Algorithm in C
  • Kruskal's Algorithm in C
  • FCFS Program in C
  • Triple DES Algorithm in C
  • Window Sliding Technique in C
  • Sleeping Barber Problem Solution in C
  • How to Add Matrix in C
  • C Program to Demonstrate fork() and pipe()
  • Deadlock Prevention using Banker's Algorithm in C
  • Simple Stopwatch Program in C
  • Add Node to Linked List in C
  • How to Add two Array in C
  • Algorithm in C language
  • Add Digits of Number in C
  • Add Element in Array in C
  • Add String in C
  • Add Two Matrices in C
  • Add two numbers using Pointer in C
  • Order of Complexity in C
  • Pattern Matching Algorithm in C
  • Adaline Program in C
  • Adam Number in C Program
  • Adam Number or not in C Program
  • Add 2 Matrix in C
  • Add 2 Strings in C
  • Add a Character to a String in C
  • Best Compiler for C Programming
  • C Program to Convert Infix to Postfix
  • C Program For Printing Inverted Pyramid
  • Control String in C Language
  • How to Find Time Complexity of a Program in C
  • Top C Projects in 2023
  • Convert a Char Array into a Double in C
  • Conio.h in C
  • Decision-Making Statements in C
  • What is Hashing in C
  • Bubble sort program in C
  • Comma Operator in C
  • Control Statements in C
  • ctype.h in C
  • First Fit Algorithm in C
  • Hello World Program in C
  • Logical operator in c
  • Memory leak in C
  • Null character in C
  • Operator precedence in C
  • Putchar() function in C
  • Quick Sort in C
  • realloc in C
  • Special operator in C
  • Volatile Keyword in C
  • CRC program in C
  • Binary search algorithm in C
  • Kruskal algorithm in C
  • Transpose of Matrix in C
  • Actual and Formal Parameters in C
  • Bit Stuffing in C
  • Difference between C and Embedded C
  • Dynamic Array in C
  • Jump statement in C
  • Multidimensional array in C
  • Priority scheduling program in C
  • Pseudo code in C
  • Data Structure in C
  • Difference between switch statement and if-else-if ladder statement in C
  • BFS Program in C
  • Nested if else statement in C
  • Pattern Programs in C
  • SJF Scheduling program in C
  • Stdlib.h in C
  • User defined function in C
  • How to use Pointers in C language
  • What is a Storage Class in C
  • What is short int in C
  • Insertion Sort in C
  • Segmentation Fault in C
  • FUNCTION PROTOTYPE IN C
  • Iteration in C
  • One dimensional array in C
  • Overview of Structures and Unions in C
  • Difference between 1D and 2D array in C
  • Differences between Float and Double in C
  • Fizz Buzz Program in C
  • Formatted and Unformatted Input Output in C
  • Garbage collection in C
  • Library function in C
  • Strtok() function in C
  • Symbolic Constants in C
  • What is Garbage Value in C
  • What is size_t in C
  • What is the use of "\r" in C
  • Address operator in C
  • BOOTHS Algorithm in C
  • Character stuffing program in C
  • Difference between printf() and scanf() in C
  • Global Variable in C
  • Lexical Analyzer in C
  • Pascal Triangle in C
  • Postfix Evaluation in C
  • Strncmp() function in C
  • Type Qualifiers in C
  • Unsigned int in C
  • What is Perror in C
  • Difference Between Array and String in C
  • Execvp() Function in C
  • Explain Recursion with Example in C
  • Contiguous file allocation program in C
  • ENTRY CONTROL LOOP IN C
  • EXIT CONTROL LOOP IN C
  • Fopen() function in C
  • Hollow Diamond Pattern in C
  • Register Keyword in C
  • Strcmpi() function in C
  • Strtol() function in C
  • System function in C
  • Difference between parameter and arguments in C
  • Execlp() function in C
  • Fabs() function in C
  • Recursive Descent Parser Program in C
  • Difference Between exit() and return() in C
  • Skill rack solution in C
  • Stack overflow in C
  • Static_cast in C
  • Stdin and Stdout in C
  • Strrchr() function in C
  • Strsep() function in C
  • Strcspn() function in C
  • Strtoul() Function in C
  • Area of Circle program in C
  • Branching statements in C
  • Bubble Sort in C
  • C program to adding of two binary numbers
  • C program to Search an Element in an Array
  • Difference between Object code and Source code
  • Electricity bill program in C
  • RSA algorithm in C
  • Singly linked list in C
  • Strftime() in C
  • Strlen() function in C
  • Swap first and last digit of a number in C
  • Addition program in C
  • clrscr in C
  • Distance Vector Routing Program in C
  • Even odd programs in C
  • How to Access Structure Members in C
  • How to Change C Users Username in Windows 10
  • Linear search in C
  • Symmetric Matrix in C
  • fgets() function in C
  • Length of array in C
  • MULTITHREADING IN C
  • Number pattern program in C
  • Strcpy() function in C
  • Best Books for C Programming
  • C Program to Calculate Area and Circumference of Circle
  • Character Set in C
  • Array Rotation in C
  • Random Access File in C
  • atan2() Function in C
  • Digital Clock in C Programming
  • How Many IP Addresses have a class c Network
  • How Many Tokens in C
  • Linked error in C
  • Lvalue and Rvalue in C
  • Auto and Static Variable in C
  • feof() function in C
  • Gauss Jordan Method in C
  • Gauss Seidel Method in C
  • Getw() and Putw() function in C
  • lseek() in C
  • usleep() function in C
  • First and Follow Program in C
  • Interpolation Search in C
  • strdup() function in C
  • Generic Keyword in C
  • getopt() function in C
  • getpid() and getppid() function in C
  • Magic Square Function in C
  • Reentrant Function in C
  • Return Statement in C
  • Travelling Salesman Problem in C
  • Double Float in C
  • fseek() vs rewind() in C
  • How to create your own header files in C
  • Implicit type conversion in C
  • Inter Function Communication in C
  • kbhit() in C
  • Multiline Macros in C
  • Scanset in C
  • Tail Recursion in C
  • C program for currency denomination
  • C program for secant method
  • Fread() Function in C
  • Hangman game program in C
  • Hilbert curve program in C
  • Newton Forward Interpolation in C
  • Tower of Hanoi
  • Vigenere Cypher Program in C
  • C language MCQ
  • C language MCQ Part 2
  • Prime Numbers List
  • Composite Numbers List
  • Square Numbers List
  • Binary Numbers List
  • Fibonacci Numbers List
  • Ounces in a Cup
  • Ounces in a Pound
  • Ounces in a Gallon
  • Ounces in a Liter
  • Ounces in a Pint
  • Ounces in a Quart
  • Ounces in a Tablespoon

C Interview

  • C Interview Questions
  • C Fundamental 1
  • C Fundamental 2
  • C Fundamental 3
  • C Fundamental 4

C Control Test

  • C Control Statement 1
  • C Control Statement 2
  • C Control Statement 3
  • C Control Statement 4

C Function Test

  • C Functions 1
  • C Functions 2
  • C Functions 3
  • C Functions 4
  • C Pointers 1
  • C Pointers 2
  • C Pointers 3
  • C Pointers 4
  • C Structure 1
  • C Structure 2
  • C Structure 3
  • C Structure 4
  • C Preprocessor 1
  • C Preprocessor 2
  • C Preprocessor 3
  • C Preprocessor 4

There are different kinds of the operators, such as arithmetic, relational, bitwise, assignment, etc., in the C programming language. 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 %=.


It is the operator used to assign the right side operand or variable to the left side variable.

Let's create a program to use the simple assignment operator in C.

The operator is used to add the left side operand to the left operand and then assign results to the left operand.

Let's create a program to use the Plus and assign operator in C.

The operator is used to subtract the left operand with the right operand and then assigns the result to the left operand.

Let's create a program to use the Subtract and Assign (-=) operator in C.

The operator is used to multiply the left operand with the right operand and then assign result to the left operand.

Let's create a program to use the multiply and assign operator (*=) in C.

An operator is used between the left and right operands, which divides the first number by the second number to return the result in the left operand.

Let's create a program to use the divide and assign operator (/=) in C.

An operator used between the left operand and the right operand divides the first number (n1) by the second number (n2) and returns the remainder in the left operand.

Let's create a program to use the divide and assign operator (%=) in C.





Latest Courses

Python

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks

Contact info

G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India

[email protected] .

Facebook

Interview Questions

Online compiler.

cppreference.com

Assignment operators.

(C++20)
(C++20)
(C++11)
(C++20)
(C++17)
(C++11)
(C++11)
General topics
(C++11)
-
-expression
block


/
(C++11)
(C++11)
(C++11)
(C++20)
(C++20)
(C++11)

expression
pointer
specifier

specifier (C++11)
specifier (C++11)
(C++11)

(C++11)
(C++11)
(C++11)
General
(C++11)
(C++20)
(C++26)
(C++11)
(C++11)
-expression
-expression
-expression
(C++11)
(C++11)
(C++17)
(C++20)
    

Assignment operators modify the value of the object.

Operator name  Syntax  Prototype examples (for class T)
Inside class definition Outside class definition
simple assignment Yes T& T::operator =(const T2& b);
addition assignment Yes T& T::operator +=(const T2& b); T& operator +=(T& a, const T2& b);
subtraction assignment Yes T& T::operator -=(const T2& b); T& operator -=(T& a, const T2& b);
multiplication assignment Yes T& T::operator *=(const T2& b); T& operator *=(T& a, const T2& b);
division assignment Yes T& T::operator /=(const T2& b); T& operator /=(T& a, const T2& b);
remainder assignment Yes T& T::operator %=(const T2& b); T& operator %=(T& a, const T2& b);
bitwise AND assignment Yes T& T::operator &=(const T2& b); T& operator &=(T& a, const T2& b);
bitwise OR assignment Yes T& T::operator |=(const T2& b); T& operator |=(T& a, const T2& b);
bitwise XOR assignment Yes T& T::operator ^=(const T2& b); T& operator ^=(T& a, const T2& b);
bitwise left shift assignment Yes T& T::operator <<=(const T2& b); T& operator <<=(T& a, const T2& b);
bitwise right shift assignment Yes T& T::operator >>=(const T2& b); T& operator >>=(T& a, const T2& b);

this, and most also return *this so that the user-defined operators can be used in the same manner as the built-ins. However, in a user-defined operator overload, any type can be used as return type (including void). can be any type including .
Definitions Assignment operator syntax Built-in simple assignment operator Assignment from an expression Assignment from a non-expression initializer clause Built-in compound assignment operator Example Defect reports See also

[ edit ] Definitions

Copy assignment replaces the contents of the object a with a copy of the contents of b ( b is not modified). For class types, this is performed in a special member function, described in copy assignment operator .

replaces the contents of the object a with the contents of b, avoiding copying if possible (b may be modified). For class types, this is performed in a special member function, described in .

(since C++11)

For non-class types, copy and move assignment are indistinguishable and are referred to as direct assignment .

Compound assignment replace the contents of the object a with the result of a binary operation between the previous value of a and the value of b .

[ edit ] Assignment operator syntax

The assignment expressions have the form

target-expr new-value (1)
target-expr op new-value (2)
target-expr - the expression to be assigned to
op - one of *=, /= %=, += -=, <<=, >>=, &=, ^=, |=
new-value - the expression (until C++11) (since C++11) to assign to the target
  • ↑ target-expr must have higher precedence than an assignment expression.
  • ↑ new-value cannot be a comma expression, because its precedence is lower.

If new-value is not an expression, the assignment expression will never match an overloaded compound assignment operator.

(since C++11)

[ edit ] Built-in simple assignment operator

For the built-in simple assignment, the object referred to by target-expr is modified by replacing its value with the result of new-value . target-expr must be a modifiable lvalue.

The result of a built-in simple assignment is an lvalue of the type of target-expr , referring to target-expr . If target-expr is a bit-field , the result is also a bit-field.

[ edit ] Assignment from an expression

If new-value is an expression, it is implicitly converted to the cv-unqualified type of target-expr . When target-expr is a bit-field that cannot represent the value of the expression, the resulting value of the bit-field is implementation-defined.

If target-expr and new-value identify overlapping objects, the behavior is undefined (unless the overlap is exact and the type is the same).

If the type of target-expr is volatile-qualified, the assignment is deprecated, unless the (possibly parenthesized) assignment expression is a or an .

(since C++20)

new-value is only allowed not to be an expression in following situations:

is of a , and new-value is empty or has only one element. In this case, given an invented variable t declared and initialized as T t = new-value , the meaning of x = new-value  is x = t. is of class type. In this case, new-value is passed as the argument to the assignment operator function selected by .   <double> z; z = {1, 2}; // meaning z.operator=({1, 2}) z += {1, 2}; // meaning z.operator+=({1, 2})   int a, b; a = b = {1}; // meaning a = b = 1; a = {1} = b; // syntax error
(since C++11)

In overload resolution against user-defined operators , for every type T , the following function signatures participate in overload resolution:

& operator=(T*&, T*);
volatile & operator=(T*volatile &, T*);

For every enumeration or pointer to member type T , optionally volatile-qualified, the following function signature participates in overload resolution:

operator=(T&, T);

For every pair A1 and A2 , where A1 is an arithmetic type (optionally volatile-qualified) and A2 is a promoted arithmetic type, the following function signature participates in overload resolution:

operator=(A1&, A2);

[ edit ] Built-in compound assignment operator

The behavior of every built-in compound-assignment expression target-expr   op   =   new-value is exactly the same as the behavior of the expression target-expr   =   target-expr   op   new-value , except that target-expr is evaluated only once.

The requirements on target-expr and new-value of built-in simple assignment operators also apply. Furthermore:

  • For + = and - = , the type of target-expr must be an arithmetic type or a pointer to a (possibly cv-qualified) completely-defined object type .
  • For all other compound assignment operators, the type of target-expr must be an arithmetic type.

In overload resolution against user-defined operators , for every pair A1 and A2 , where A1 is an arithmetic type (optionally volatile-qualified) and A2 is a promoted arithmetic type, the following function signatures participate in overload resolution:

operator*=(A1&, A2);
operator/=(A1&, A2);
operator+=(A1&, A2);
operator-=(A1&, A2);

For every pair I1 and I2 , where I1 is an integral type (optionally volatile-qualified) and I2 is a promoted integral type, the following function signatures participate in overload resolution:

operator%=(I1&, I2);
operator<<=(I1&, I2);
operator>>=(I1&, I2);
operator&=(I1&, I2);
operator^=(I1&, I2);
operator|=(I1&, I2);

For every optionally cv-qualified object type T , the following function signatures participate in overload resolution:

& operator+=(T*&, );
& operator-=(T*&, );
volatile & operator+=(T*volatile &, );
volatile & operator-=(T*volatile &, );

[ edit ] Example

Possible output:

[ edit ] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
C++11 for assignments to class type objects, the right operand
could be an initializer list only when the assignment
is defined by a user-defined assignment operator
removed user-defined
assignment constraint
C++11 E1 = {E2} was equivalent to E1 = T(E2)
( is the type of ), this introduced a C-style cast
it is equivalent
to E1 = T{E2}
C++20 compound assignment operators for volatile
-qualified types were inconsistently deprecated
none of them
is deprecated
C++11 an assignment from a non-expression initializer clause
to a scalar value would perform direct-list-initialization
performs copy-list-
initialization instead
C++20 bitwise compound assignment operators for volatile types
were deprecated while being useful for some platforms
they are not
deprecated

[ edit ] See also

Operator precedence

Operator overloading

Common operators

a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b
a <=> b

a[...]
*a
&a
a->b
a.b
a->*b
a.*b

function call
a(...)
comma
a, b
conditional
a ? b : c
Special operators

converts one type to another related type
converts within inheritance hierarchies
adds or removes -qualifiers
converts type to unrelated type
converts one type to another by a mix of , , and
creates objects with dynamic storage duration
destructs objects previously created by the new expression and releases obtained memory area
queries the size of a type
queries the size of a (since C++11)
queries the type information of a type
checks if an expression can throw an exception (since C++11)
queries alignment requirements of a type (since C++11)

for Assignment operators
  • Recent changes
  • Offline version
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • Permanent link
  • Page information
  • In other languages
  • This page was last modified on 25 January 2024, at 23:41.
  • Privacy policy
  • About cppreference.com
  • Disclaimers

Powered by MediaWiki

  • C++ Data Types
  • C++ Input/Output
  • C++ Pointers
  • C++ Interview Questions
  • C++ Programs
  • C++ Cheatsheet
  • C++ Projects
  • C++ Exception Handling
  • C++ Memory Management

Assignment Operators In C++

In C++, the assignment operator forms the backbone of many algorithms and computational processes by performing a simple operation like assigning a value to a variable. It is denoted by equal sign ( = ) and provides one of the most basic operations in any programming language that is used to assign some value to the variables in C++ or in other words, it is used to store some kind of information.

The right-hand side value will be assigned to the variable on the left-hand side. The variable and the value should be of the same data type.

The value can be a literal or another variable of the same data type.

 

Compound Assignment Operators

In C++, the assignment operator can be combined into a single operator with some other operators to perform a combination of two operations in one single statement. These operators are called Compound Assignment Operators. There are 10 compound assignment operators in C++:

  • Addition Assignment Operator ( += )
  • Subtraction Assignment Operator ( -= )
  • Multiplication Assignment Operator ( *= )
  • Division Assignment Operator ( /= )
  • Modulus Assignment Operator ( %= )
  • Bitwise AND Assignment Operator ( &= )
  • Bitwise OR Assignment Operator ( |= )
  • Bitwise XOR Assignment Operator ( ^= )
  • Left Shift Assignment Operator ( <<= )
  • Right Shift Assignment Operator ( >>= )

Lets see each of them in detail.

1. Addition Assignment Operator (+=)

In C++, the addition assignment operator (+=) combines the addition operation with the variable assignment allowing you to increment the value of variable by a specified expression in a concise and efficient way.

This above expression is equivalent to the expression:

   

2. Subtraction Assignment Operator (-=)

The subtraction assignment operator (-=) in C++ enables you to update the value of the variable by subtracting another value from it. This operator is especially useful when you need to perform subtraction and store the result back in the same variable.

   

3. Multiplication Assignment Operator (*=)

In C++, the multiplication assignment operator (*=) is used to update the value of the variable by multiplying it with another value.

 

4. Division Assignment Operator (/=)

The division assignment operator divides the variable on the left by the value on the right and assigns the result to the variable on the left.

       

5. Modulus Assignment Operator (%=)

The modulus assignment operator calculates the remainder when the variable on the left is divided by the value or variable on the right and assigns the result to the variable on the left.

     

6. Bitwise AND Assignment Operator (&=)

This operator performs a bitwise AND between the variable on the left and the value on the right and assigns the result to the variable on the left.

   

7. Bitwise OR Assignment Operator (|=)

The bitwise OR assignment operator performs a bitwise OR between the variable on the left and the value or variable on the right and assigns the result to the variable on the left.

8. Bitwise XOR Assignment Operator (^=)

The bitwise XOR assignment operator performs a bitwise XOR between the variable on the left and the value or variable on the right and assigns the result to the variable on the left.

9. Left Shift Assignment Operator (<<=)

The left shift assignment operator shifts the bits of the variable on the left to left by the number of positions specified on the right and assigns the result to the variable on the left.

10. Right Shift Assignment Operator (>>=)

The right shift assignment operator shifts the bits of the variable on the left to the right by a number of positions specified on the right and assigns the result to the variable on the left.

Also, it is important to note that all of the above operators can be overloaded for custom operations with user-defined data types to perform the operations we want.

Please Login to comment...

Similar reads.

  • Geeks Premier League
  • Geeks Premier League 2023
  • Best External Hard Drives for Mac in 2024: Top Picks for MacBook Pro, MacBook Air & More
  • How to Watch NFL Games Live Streams Free
  • OpenAI o1 AI Model Launched: Explore o1-Preview, o1-Mini, Pricing & Comparison
  • How to Merge Cells in Google Sheets: Step by Step Guide
  • #geekstreak2024 – 21 Days POTD Challenge Powered By Deutsche Bank

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

C Compound Assignment

  • 6 contributors

The compound-assignment operators combine the simple-assignment operator with another binary operator. Compound-assignment operators perform the operation specified by the additional operator, then assign the result to the left operand. For example, a compound-assignment expression such as

expression1 += expression2

can be understood as

expression1 = expression1 + expression2

However, the compound-assignment expression is not equivalent to the expanded version because the compound-assignment expression evaluates expression1 only once, while the expanded version evaluates expression1 twice: in the addition operation and in the assignment operation.

The operands of a compound-assignment operator must be of integral or floating type. Each compound-assignment operator performs the conversions that the corresponding binary operator performs and restricts the types of its operands accordingly. The addition-assignment ( += ) and subtraction-assignment ( -= ) operators can also have a left operand of pointer type, in which case the right-hand operand must be of integral type. The result of a compound-assignment operation has the value and type of the left operand.

In this example, a bitwise-inclusive-AND operation is performed on n and MASK , and the result is assigned to n . The manifest constant MASK is defined with a #define preprocessor directive.

C Assignment Operators

Was this page helpful?

Additional resources

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

What is the assignment-expression in array brackets in C?

In C89 A.1.2.2 Declarations

direct-declarator [ constant-expression ]

In C99 A.2.2 Declarations

direct-declarator [ type-qualifier-list_opt assignment-expression_opt ]

I understand assignment-expression_opt as var = 1; . But arrays are not declared like int arr[i = 0]; . Why does C99 use the term "assignment-expression" instead of "constant-expression"and what does it mean?

  • language-lawyer

op ol's user avatar

  • 1 Variadic-length arrays can be declared like that, so that's why the wider class, I guess (constant expressions are effectively a subset of assignment expressions). Keep in mind that 4 or x ? a : b are also grammatically reducible to assignment expressions in the right contexts. –  Petr Skocik Commented Jan 13, 2022 at 14:32

2 Answers 2

In C89 there was no support for variable length arrays. This means that array sizes must be fixed at compile time.

Starting with C99, declarations and statements may be mixed within a block, so full expressions that must be executed are now allowed as an initializer. This also is what allows for variable length arrays to be created.

So a declaration like int arr[i=0]; is valid syntax, although it's invalid because it created an array of size 0. int arr[i=2]; is valid and will create arr as an array of int of size 2, and it sets i to 2.

dbush's user avatar

This is because C99 supports VLA and whatever goes between [] may then be pretty much any expression.

As for why it says assignment-expression specifically:

The way the syntax of expressions and operator precedence is described in C, is by having each operator group's syntax point at the operator group with higher precedence than itself. For example look at the syntax for an assignment expression:

assignment-expression: conditional-expression

It points at the conditional ?: operator which will be the next operator group with higher precedence than assignment operators.

And for the comma operator with lowest precedence of all, the syntax is actually:

expression: assignment-expression expression , assignment-expression

That is, the syntax for an expression in C. Now for some reason, C99 apparently didn't want to allow comma operators inside [] . I don't know why - perhaps it would make qualified/static array parameter declarators too strange. So instead of using expression in the direct-declarator syntax, they picked the next operator group above the comma operator, the assignment operators.

Lundin's user avatar

  • 1 maybe because some languages use A[x,y] syntax to access 2d arrays while C requires A[x][y] . It may result in difficult to spot errors. –  tstanisl Commented Jan 13, 2022 at 15:46

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged c language-lawyer or ask your own question .

  • The Overflow Blog
  • Looking under the hood at the tech stack that powers multimodal AI
  • Featured on Meta
  • User activation: Learnings and opportunities
  • Preventing unauthorized automated access to the network
  • What does a new user need in a homepage experience on Stack Overflow?
  • Announcing the new Staging Ground Reviewer Stats Widget

Hot Network Questions

  • Which law(s) bans medical exams without a prescription?
  • Email from Deutsche Bahn about a timetable change - what do I need to do?
  • What is a “bearded” oyster?
  • Model looks dented but geometry is correct
  • How safe is the runastool.exe, any known issues?
  • Why Doesn't the cooling system on a rocket engine burn the fuel?
  • Is there a "hard problem of aesthetics?"
  • How can "chemical-free" surface cleaners work?
  • How to do smooth merging of two points using tikzpicture
  • Consequences of registering a PhD at german university?
  • If directly exposed to the vacuum of space, what would be the effects on a womans reproductive system?
  • Numerical integration of ODEs: Why does higher accuracy and precision not lead to convergence?
  • Calculate transition probabilities
  • How can I add cache information to InboundPathProcessor?
  • Why believe in the existence of large cardinals rather than just their consistency?
  • Access and modify attributes of svg markup elements
  • What's wrong with using the word "Credit" in a table header using spreadtab and siunitx?
  • Was the total glaciation of the world, a.k.a. snowball earth, due to Bok space clouds?
  • How to react to a rejection based on a single one-line negative review?
  • If morality is real and has causal power, could science detect the moment the "moral ontology" causes a measurable effect on the physical world?
  • Why should the simulator be PPT in simulation-based security?
  • Smallest prime q such that concatenation (p+q)"q is a prime
  • Parameters of the sampling distribution of the sample proportion
  • Fear of getting injured in Judo

assignment expression in c

IMAGES

  1. Pointer Expressions in C with Examples

    assignment expression in c

  2. 23 Assignment Operators & Expressions in C Programming Language

    assignment expression in c

  3. How to Use Assignment Operator in C

    assignment expression in c

  4. Evaluate an Expression in C Example 4 Assignment

    assignment expression in c

  5. Assignment Operators in C with Examples

    assignment expression in c

  6. PPT

    assignment expression in c

VIDEO

  1. Assignment Operator in C Programming

  2. W. Mathematical Expression || C || Bangla || Assiut University Training

  3. NPTEL The Joy of Computing using Python week 4 quiz assignment answers (check proof in description)

  4. Augmented assignment operators in C

  5. Assignment Operator in C Programming

  6. expression # c #comedy #funny #youtubeshorts viral #shortvideo

COMMENTS

  1. Assignment Operators in C

    1. "=": This is the simplest assignment operator. This operator is used to assign the value on the right to the variable on the left. Example: a = 10;b = 20;ch = 'y'; 2. "+=": This operator is combination of '+' and '=' operators. This operator first adds the current value of the variable on left to the value on the right and ...

  2. What is the result of an assignment expression in C?

    1. This is an infinite loop. It first assign 10 to c, then compare it with c > 0, then again loop starts, assign 10 to c, compare it with c>0 and so on. Loop never ends. This is equivalent to the following: while(c=10); /* Because c assign a garbage value, but not true for all cases maybe it assign 0 */. while(c);

  3. Assignment Expressions (GNU C Language Manual)

    7 Assignment Expressions. As a general concept in programming, an assignment is a construct that stores a new value into a place where values can be stored—for instance, in a variable. Such places are called lvalues (see Lvalues) because they are locations that hold a value. An assignment in C is an expression because it has a value; we call it an assignment expression.

  4. c

    An assignment expression has the value of the left operand after the assignment. It's to allow things like this: a = b = c; (although there's some debate as to whether code like that is a good thing or not.) Incidentally, this behaviour is replicated in Java (and I would bet that it's the same in C# too). edited Feb 20, 2017 at 8:59.

  5. Assignment operators

    Assignment performs implicit conversion from the value of rhs to the type of lhs and then replaces the value in the object designated by lhs with the converted value of rhs. Assignment also returns the same value as what was stored in lhs (so that expressions such as a = b = c are possible). The value category of the assignment operator is non ...

  6. C Assignment Operators

    Syntax. The assignment operators in C can both transform and assign values in a single operation. C provides the following assignment operators: | =. In assignment, the type of the right-hand value is converted to the type of the left-hand value, and the value is stored in the left operand after the assignment has taken place.

  7. Assignment Operators in C

    Simple assignment operator. Assigns values from right side operands to left side operand. C = A + B will assign the value of A + B to C. +=. Add AND assignment operator. It adds the right operand to the left operand and assign the result to the left operand. C += A is equivalent to C = C + A. -=.

  8. C Programming Assignment Operators

    Assignment Operators in C are used to assign values to the variables. They come under the category of binary operators as they require two operands to operate upon. The left side operand is called a variable and the right side operand is the value. The value on the right side of the "=" is assigned to the variable on the left side of "=".

  9. Assignment Operators in C with Examples

    Assignment operators are used to assign value to a variable. The left side of an assignment operator is a variable and on the right side, there is a value, variable, or an expression. It computes the outcome of the right side and assign the output to the variable present on the left side. C supports following Assignment operators: 1.

  10. Chapter 7

    Assignment as an Expression In C-like languages, an assignment statement itself can be an expression; i.e., the result of the assignment becomes an operand for the expression; e.g.,: while ((ch = getchar())!= EOF){. . .} ch = getchar() is carried out; the result is assigned to ch and becomes the lefthand side of the != operator.

  11. c++

    The result of the assignment operation is the value stored in the left operand after the assignment has taken place; the result is an lvalue. The result of the expression a = 5 is 5. [6.4/4] [..] The value of a condition that is an expression is the value of the expression, implicitly converted to bool for statements other than switch.

  12. Operators in C

    5. Assignment Operators in C. Assignment operators are used to assign 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. The value on the right side must be of the same data type as the variable on the left side otherwise the compiler will raise ...

  13. Assignment statements in C/C++

    Assignment statement in C/C++: The assignment statement is used to assign a value (computed from an expression) to a variable Syntax: Variable = Expression ; Notice . The expression (value) has a type , and The variable has a type , and The ...

  14. Expression Statement (GNU C Language Manual)

    19.1 Expression Statement. The most common kind of statement in C is an expression statement.It consists of an expression followed by a semicolon. The expression's value is discarded, so the expressions that are useful are those that have side effects: assignment expressions, increment and decrement expressions, and function calls.

  15. Assignment Operator in C

    Simple Assignment Operator (=): It is the operator used to assign the right side operand or variable to the left side variable. Syntax. int a = 5; or int b = a; ch = 'a'; int a = 5; or int b = a; ch = 'a'; Let's create a program to use the simple assignment operator in C. Program1.c.

  16. Assignment operators

    Correct behavior. CWG 1527. C++11. for assignments to class type objects, the right operand could be an initializer list only when the assignment is defined by a user-defined assignment operator. removed user-defined assignment constraint. CWG 1538. C++11. E1 ={E2} was equivalent to E1 = T(E2) (T is the type of E1), this introduced a C-style cast.

  17. Conditional or Ternary Operator (?:) in C

    The working of the conditional operator in C is as follows: Step 1: Expression1 is the condition to be evaluated. Step 2A: If the condition (Expression1) is True then Expression2 will be executed. Step 2B: If the condition (Expression1) is false then Expression3 will be executed. Step 3: Results will be returned.

  18. Assignment operators

    The result of an assignment expression is always an l-value. These operators have right-to-left associativity. The left operand must be a modifiable l-value. In ANSI C, the result of an assignment expression isn't an l-value. That means the legal C++ expression (a += b) += c isn't allowed in C. See also. Expressions with binary operators

  19. Assignment Operators In C++

    1. Addition Assignment Operator (+=) In C++, the addition assignment operator (+=) combines the addition operation with the variable assignment allowing you to increment the value of variable by a specified expression in a concise and efficient way. Syntax. variable += value; This above expression is equivalent to the expression:

  20. C Compound Assignment

    The compound-assignment operators combine the simple-assignment operator with another binary operator. Compound-assignment operators perform the operation specified by the additional operator, then assign the result to the left operand. For example, a compound-assignment expression such as. expression1 += expression2. can be understood as.

  21. What is the assignment-expression in array brackets in C?

    And for the comma operator with lowest precedence of all, the syntax is actually: expression: assignment-expression. expression , assignment-expression. That is, the syntax for an expression in C. Now for some reason, C99 apparently didn't want to allow comma operators inside []. I don't know why - perhaps it would make qualified/static array ...