Q:

C++ calculate values dynamically like in a spreadsheet?

Is it possible to for values to dynamically be calculated in C++ like in a spreadsheet (in reaction to another variable been changed) ?
For example:
int x;
y = 2 * x;
cin >> x;
cout << y;

I want to make it so that I can modify x repeatedly and cout << y will show the recalculated value, instead of having to close the program or endl and input again to enter a different value of x. (See picture)

A:

No coding can be done in this way. When the variable is defined, free space is given from the memory, but no arithmetic processing can be done because no value assignment is made.

