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
</>
Copy
x = 2
Example
In the following example, we assign a value of 2
to x
using Simple Assignment Operator.
main.cpp
</>
Copy
#include <iostream>
using namespace std;
int main() {
//simple assignment
int x = 2;
cout << "x : " << x << endl;
}
Output
x : 2
Program ended with exit code: 0
Conclusion
In this C++ Tutorial, we learned about Simple Assignment Operator in C++, with examples.