C++ program to perform the assignment operations
kw.cpp
#include <iostream>
using namespace std;
int main()
{
    int a = 0, b = 1;
    cout<<"———————————————————————————————————————————";
    cout<<"\nProgram to perform the assignment operations ";
    cout<<"\n———————————————————————————————————————————";
    cout<<"\nValue of a      | "<<a;
    cout<<"\nValue of b      | "<<b;
    cout<<"\nValue of "<<a<<" += "<<b<<" | "<<(a += b);
    cout<<"\nValue of "<<a<<" -= "<<b<<" | "<<(a -= b);
    cout<<"\nValue of "<<a<<" *= "<<b<<" | "<<(a *= b);
    cout<<"\nValue of "<<a<<" /= "<<b<<" | "<<(a /= b);
    cout<<"\nValue of "<<a<<" %= "<<b<<" | "<<(a %= b);
    cout<<"\nValue of "<<a<<" ^= "<<b<<" | "<<(a ^= b);
    cout<<"\nValue of "<<a<<" |= "<<b<<" | "<<(a |= b);
    cout<<"\nValue of "<<a<<" &= "<<b<<" | "<<(a &= b);
    cout<<"\n———————————————————————————————————————————\n";
    return 0;
}
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program to perform the assignment operations ——————————————————————————————————————————— Value of a | 0 Value of b | 1 Value of 0 += 1 | 1 Value of 1 -= 1 | 0 Value of 0 *= 1 | 0 Value of 0 /= 1 | 0 Value of 0 %= 1 | 0 Value of 0 ^= 1 | 1 Value of 1 |= 1 | 1 Value of 1 &= 1 | 1 ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement