How can I make a variable always equal to the result of some calculations?

How can I make a variable always equal to the result of some calculations?

In math, if&nbsp;<code>z = x+y/2</code>, then&nbsp;<code>z</code>&nbsp;will always change whenever we replace the value of&nbsp;<code>x</code>&nbsp;and&nbsp;<code>y</code>. Can we do that in programming without having to specifically updating&nbsp;<code>z</code>&nbsp;whenever we change the value of&nbsp;<code>x</code>&nbsp;and&nbsp;<code>y</code>?

In math, if z = x+y/2, then z will always change whenever we replace the value of x and y. Can we do that in programming without having to specifically updating z whenever we change the value of x and y?

I mean something like that won't work, right?

int x;
int y;
int z{x + y};
cin >> x;
cin >> y;
cout << z;

If you're confused why I would need that, I want the variable shown live, and get it updated automatically when a rhs-variable make changes.

Like when killing a creep and get gold, then the net-worth (cash+worth of own items) shown changes. Or the speed meter of a car changing depending on how slow or fast you're driving.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

Variable Introduction in C#[Bangla]

LIKE | COMMENT | SHARE | SUBSCRIBE A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a speci...