Variables in C++
C++ has a variety of operators that can be used to create expressions. These operators can be divided into the following categories: arithmetic, logical, relational, bitwise, and assignment operators.
Let’s look at an example of an expression using the arithmetic operators:
#include <iostream>
int main()
{
int x = 10;
int y = 5;
int z = x + y;
std::cout << "x + y = " << z << std::endl;
return 0;
}
Output
x + y = 15
In this example, we have used the addition operator (+) to add the values of x and y and store the result in the variable z. We have then used the cout stream to print out the value of z.