- Introduction to C Programming
- Features And Importance
- Standard Library
- Programming in C
- Data Types
- Variables
- Constants
- Storage Classes
- Static Storage Class
- Scope Rules
- Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
- Operator Precedence in C
- Control Structures
- Program Controls
- Loop Control Statement
- Functions
- Arrays
- Array Definition
- Array initialization
- Static and Automatic Arrays
- Single Dimensional Array
- Multi Dimensional Array
- Array Definition
- Array initialization
- Static and Automatic Arrays
- Single Dimensional Array
- Multi Dimensional Array
- Array Definition
- Array initialization
- Static and Automatic Arrays
- Single Dimensional Array
- Multi Dimensional Array
- Array Definition
- Array initialization
- Static and Automatic Arrays
- Single Dimensional Array
- Multi Dimensional Array
- Array Definition
- Array initialization
- Static and Automatic Arrays
- Single Dimensional Array
- Multi Dimensional Array
- Pointers
- Definitions and Initialization
- Pointers Operators
- Pointer Expression and Arithmetic
- Pointer-Array Relationship
- Array of Pointers
- Definitions and Initialization
- Pointers Operators
- Pointer Expression and Arithmetic
- Pointer-Array Relationship
- Array of Pointers
- Definitions and Initialization
- Pointers Operators
- Pointer Expression and Arithmetic
- Pointer-Array Relationship
- Array of Pointers
- Definitions and Initialization
- Pointers Operators
- Pointer Expression and Arithmetic
- Pointer-Array Relationship
- Array of Pointers
- Definitions and Initialization
- Pointers Operators
- Pointer Expression and Arithmetic
- Pointer-Array Relationship
- Array of Pointers
- Characters and Strings
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Character Handling Library
- String-Conversion Functions
- Standard I/O Functions
- String-Manipulation Functions
- Comparison Functions
- Search Functions
- Memory Functions
- Remaining Functions
- Structures
- typedef
- Unions
- Enumeration Constants
- File Processing
- Preprocessors
- Header Files
- Recursion
- Variable Argument
- Command Line Arguments
- Memory Management
- Typecasting
Assignment Operators
C has several assignment operators available one simple assignment operator and several convenience assignment operators that combine arithmetic or bitwise operations with the assignment. The operators are as follows:
Operator |
Description |
Example |
---|---|---|
= |
Simple assignment operator. Assigns values from right side operands to left side operands |
num3 = num1 + num2 will assign the value of num1 + num2 to num3 |
+= |
Add AND assignment operator. It adds the right operand to the left operand and assigns the result to the left |
num3+= num1 is equivalent to num3 = num3 + num1 |
-= |
Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. |
num3-= num1 is equivalent to num3 = num3 - num1 |
*= |
Multiply AND assignment operator. It multiplies the right operand with the left operand and assigns the result to the left operand. |
num3*= num1 is equivalent to num3 = num3 * num1 |
/= |
Divide AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand. |
num3/= num1 is equivalent to num3 = num3 / num1 |
%= |
Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand. |
num3%= num1 is equivalent to num3 = num3 %num1 |
<<= |
Left shift AND assignment operator. |
num3<<=5 is same as num3 = num3<<5 |
>>= |
Right shift AND assignment operator. |
num3>>=5 is same as num3 = num3>>5 |
&= |
Bitwise AND assignment operator |
num3&=5 is same as num3 = num3&5 |
^= |
Bitwise exclusive OR and assignment operator. |
num3^=5 is same as num3 = num3^5 |
|= |
Bitwise inclusive OR and assignment operator. |
num3|=5 is same as num3 = num3|5 |
Example
/*A C program for Assignment operator */
#include <stdio.h>
main()
{
int num1 = 25;
int num3 ;
num3 = num1;
printf("Line 1 - = Value of num3 = %d\n", num3 );
num3 += num1;
printf("Line 2 - += Value of num3 = %d\n", num3 );
num3 -= num1;
printf("Line 3 - -= Value of num3 = %d\n", num3 );
num3 *= num1;
printf("Line 4 - *= Value of num3 = %d\n", num3 );
num3 /= num1;
printf("Line 5 - /= Value of num3 = %d\n", num3 );
num3 = 200;
num3 %= num1;
printf("Line 6 - %= Value of num3 = %d\n", num3 );
num3 <<= 2;
printf("Line 7 - <<= Value of num3 = %d\n", num3 );
num3 >>= 2;
printf("Line 8 - >>= Value of num3 = %d\n", num3 );
num3 &= 2;
printf("Line 9 - &= Value of num3 = %d\n", num3 );
num3 ^= 2;
printf("Line 10 - ^= Value of num3= %d\n", num3 );
num3 |= 2;
printf("Line 11 - |= Value of num3 = %d\n", num3 );
}
Output
Line 1 - = Value of num3 = 21
Line 2 - += Value of num3 = 42
Line 3 - -= Value of num3 = 21
Line 4 - *= Value of num3 = 441
Line 5 - /= Value of num3 = 21
Line 6 - %= Value of num3 = 11
Line 7 - <<= Value of num3 = 44
Line 8 - >>= Value of num3 = 11
JOIN TUTORIALS LINK
Our Newsletter Will Let You Know When Any New
Articles, Tutorials and Video Are Released.
CONTRIBUTE
MOBILE APP
