Assignment Operators in C
Here are the implementation of Assignment Operator in C language:
#include <stdio.h>
int main() {
int num = 10; // Initialization
// Using various assignment operators
num += 5; // Equivalent to: num = num + 5;
printf("+= operator: %d\n", num); // Output: 15
num -= 3; // Equivalent to: num = num - 3;
printf("-= operator: %d\n", num); // Output: 12
num *= 2; // Equivalent to: num = num * 2;
printf("*= operator: %d\n", num); // Output: 24
num /= 4; // Equivalent to: num = num / 4;
printf("/= operator: %d\n", num); // Output: 6
num %= 5; // Equivalent to: num = num % 5;
printf("%= operator: %d\n", num); // Output: 1
return 0;
}
Output
+= operator: 15 -= operator: 12 *= operator: 24 /= operator: 6 %= operator: 1
Assignment Operators in Programming
Assignment operators in programming are symbols used to assign values to variables. They offer shorthand notations for performing arithmetic operations and updating variable values in a single step. These operators are fundamental in most programming languages and help streamline code while improving readability.
Table of Content
- What are Assignment Operators?
- Types of Assignment Operators
- Assignment Operators in C
- Assignment Operators in C++
- Assignment Operators in Java
- Assignment Operators in Python
- Assignment Operators in C#
- Assignment Operators in Javascript
- Application of Assignment Operators