Assignment Operators

Assignment operators are used to assign values to variables. In C, the basic assignment operator is `=`. Other compound assignment operators combine assignment with another operation.

Basic Assignment Example:


#include <stdio.h>
int main() {
    int a;
    a = 10;
    printf("Value of a: %d\n", a);
    return 0;
}

Output

Value of a: 10

Compound Assignment Example:


#include <stdio.h>
int main() {
    int a = 10;
    a += 5; // Same as a = a + 5
    printf("Value of a after compound assignment: %d\n", a);
    return 0;
}

Output

Value of a after compound assignment: 15