Skip to main content
Back to Blog
Programming Languages
14 August 20263 min readUpdated 14 August 2026

Mastering Variable Declarations in C++

cpp int x = 10, y = 10, z = 100; std::cout << x + y + z;

Mastering Variable Declarations in C++
## Declaring Multiple Variables in C++

## Declaring Several Variables at Once

When you need to declare multiple variables of the same type in C++, you can do so efficiently by using a comma-separated list. This method helps streamline your code and keeps it organized.

## Assigning One Value to Multiple Variables

It's possible to assign the same value to multiple variables in a single line, simplifying your code and promoting readability.

```cpp
int x = 10, y = 10, z = 100;
std::cout << x + y + z;

This snippet demonstrates declaring three integer variables (x, y, and z) and assigning them values. The cout statement then outputs the sum of these variables.