# 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.

## Dicey Issues in C/C++

C/C++ problems. If you are familiar with C/C++then you must have come across some unusual things and if you havenâ€™t, then you are about to. The below codes are checked twice before adding, so feel free to share this article with your friends.

## Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

## Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look

## C++ Tutorial for Beginners 19 - C++ Structures | Struct declaration | C++ Data Structures

Welcome to this course on C++ Tutorial for Beginners. In this video we will see How to use C++ Structures.

## Object Oriented Programming in C++ | C++ OOPs Concepts | Learn Object Oriented C++

C++ is general purpose, compiled, object-oriented programming language and its concepts served as the basis for several other languages such as Java, Python, Ruby, Perl etc.