In this C++ tutorial, you shall learn about Simple Assignment operator, its syntax, and how to use this operator, with examples.

C++ Simple Assignment

In C++, Simple Assignment Operator is used to assign a value to a variable.

The syntax to assign a value of 2 to variable x using Simple Assignment Operator is

x = 2


In the following example, we assign a value of 2 to x using Simple Assignment Operator.


#include <iostream>
using namespace std;

int main() {
    //simple assignment
    int x = 2;
    cout << "x : " << x << endl;


x : 2
Program ended with exit code: 0


In this C++ Tutorial, we learned about Simple Assignment Operator in C++, with examples.