bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/C++/C++ Tutorial
C++•C++ Tutorial

C++ Declare Multiple Variables

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind C++ Declare Multiple Variables?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ x = 5, y = 6, z = 50;
3Order

Put the learning moves in the order that makes the concept easiest to apply.

To declare more than one variable of the same type , use a comma-separated list:
One Value to Multiple Variables
Declare Many Variables

Declare Many Variables

To declare more than one variable of the same type , use a comma-separated list:

Example

int x = 5, y = 6, z = 50;
cout << x + y + z;

One Value to Multiple Variables

You can also assign the same value to multiple variables in one line:

Example

int x, y, z;
x = y = z = 50;
cout << x + y + z;

Previous

C++ Variables

Next

C++ Identifiers